@Override public Exception deserializeException(ByteBuffer buffer, int length) throws Exception { if (length < FID_CODE_SIZE) { throw new IllegalStateException("Message size too small: " + length); } byte fid = buffer.get(); if (fid != FunctionId.OTHER.ordinal()) { throw new IllegalStateException("Expected FID for OTHER, found: " + fid); } return (Exception) deserialize(fid, buffer, length - FID_CODE_SIZE); }
private byte[] serialize(Object object, byte fid) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); baos.write(fid); try { serialize(baos, object, fid); } catch (Exception e) { LOGGER.log(Level.ERROR, "Error serializing " + object, e); throw e; } baos.close(); return baos.toByteArray(); }
@Override public void start() throws Exception { LOGGER.log(Level.INFO, "Starting NodeControllerService"); ipc = new IPCSystem(new InetSocketAddress(ncConfig.getClusterListenAddress(), ncConfig.getClusterListenPort()), networkSecurityManager.getSocketChannelFactory(), new NodeControllerIPCI(this), new CCNCFunctions.SerializerDeserializer()); ipc.start(); partitionManager = new PartitionManager(this); netManager = new NetworkManager(ncConfig.getDataListenAddress(), ncConfig.getDataListenPort(), partitionManager, ncConfig.getNetThreadCount(), ncConfig.getNetBufferCount(), ncConfig.getDataPublicAddress(), ncConfig.getDataPublicPort(), FullFrameChannelInterfaceFactory.INSTANCE, networkSecurityManager.getSocketChannelFactory()); netManager.start(); startApplication(); init(); resultNetworkManager.start(); if (messagingNetManager != null) { messagingNetManager.start(); } initNodeControllerState(); hbTask = new HeartbeatComputeTask(this); primaryCcId = addCc(new InetSocketAddress(ncConfig.getClusterAddress(), ncConfig.getClusterPort())); workQueue.start(); // Schedule heartbeat data updates timer.schedule(hbTask, HEARTBEAT_REFRESH_MILLIS, HEARTBEAT_REFRESH_MILLIS); // Schedule tracing a human-readable datetime timer.schedule(new TraceCurrentTimeTask(serviceCtx.getTracer()), 0, 60000); LOGGER.log(Level.INFO, "Started NodeControllerService"); application.startupCompleted(); }
@Override public void start() throws Exception { LOGGER.log(Level.INFO, "Starting ClusterControllerService: " + this); serverCtx = new ServerContext(ServerContext.ServerType.CLUSTER_CONTROLLER, new File(ccConfig.getRootDir())); IIPCI ccIPCI = new ClusterControllerIPCI(this); clusterIPC = new IPCSystem(new InetSocketAddress(ccConfig.getClusterListenPort()), networkSecurityManager.getSocketChannelFactory(), ccIPCI, new CCNCFunctions.SerializerDeserializer()); IIPCI ciIPCI = new ClientInterfaceIPCI(this, jobIdFactory); clientIPC = new IPCSystem(new InetSocketAddress(ccConfig.getClientListenAddress(), ccConfig.getClientListenPort()), networkSecurityManager.getSocketChannelFactory(), ciIPCI, new JavaSerializationBasedPayloadSerializerDeserializer()); webServer = new WebServer(this, ccConfig.getConsoleListenPort()); clusterIPC.start(); clientIPC.start(); webServer.start(); info = new ClusterControllerInfo(ccId, ccConfig.getClientPublicAddress(), ccConfig.getClientPublicPort(), ccConfig.getConsolePublicPort()); timer.schedule(sweeper, 0, ccConfig.getDeadNodeSweepThreshold()); jobLog.open(); startApplication(); resultDirectoryService.init(executor); workQueue.start(); connectNCs(); LOGGER.log(Level.INFO, "Started ClusterControllerService"); notifyApplication(); }
@Override public byte[] serializeException(Exception object) throws Exception { return serialize(object, (byte) FunctionId.OTHER.ordinal()); }
@Override public Object deserializeObject(ByteBuffer buffer, int length) throws Exception { if (length < FID_CODE_SIZE) { throw new IllegalStateException("Message size too small: " + length); } byte fid = buffer.get(); return deserialize(fid, buffer, length - FID_CODE_SIZE); }