Search in sources :

Example 1 with IPCSystem

use of org.apache.hyracks.ipc.impl.IPCSystem in project asterixdb by apache.

the class IPCTest method test.

@Test
public void test() throws Exception {
    IPCSystem server = createServerIPCSystem();
    server.start();
    InetSocketAddress serverAddr = server.getSocketAddress();
    RPCInterface rpci = new RPCInterface();
    IPCSystem client = createClientIPCSystem(rpci);
    client.start();
    IIPCHandle handle = client.getHandle(serverAddr);
    for (int i = 0; i < 100; ++i) {
        Assert.assertEquals(rpci.call(handle, Integer.valueOf(i)), Integer.valueOf(2 * i));
    }
    try {
        rpci.call(handle, "Foo");
        Assert.assertTrue(false);
    } catch (Exception e) {
        Assert.assertTrue(true);
    }
}
Also used : IIPCHandle(org.apache.hyracks.ipc.api.IIPCHandle) InetSocketAddress(java.net.InetSocketAddress) RPCInterface(org.apache.hyracks.ipc.api.RPCInterface) IOException(java.io.IOException) IPCException(org.apache.hyracks.ipc.exceptions.IPCException) IPCSystem(org.apache.hyracks.ipc.impl.IPCSystem) Test(org.junit.Test)

Example 2 with IPCSystem

use of org.apache.hyracks.ipc.impl.IPCSystem in project asterixdb by apache.

the class ClusterControllerService method start.

@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()), ccIPCI, new CCNCFunctions.SerializerDeserializer());
    IIPCI ciIPCI = new ClientInterfaceIPCI(this);
    clientIPC = new IPCSystem(new InetSocketAddress(ccConfig.getClientListenAddress(), ccConfig.getClientListenPort()), ciIPCI, new JavaSerializationBasedPayloadSerializerDeserializer());
    webServer = new WebServer(this, ccConfig.getConsoleListenPort());
    clusterIPC.start();
    clientIPC.start();
    webServer.start();
    info = new ClusterControllerInfo(ccConfig.getClientListenAddress(), ccConfig.getClientListenPort(), webServer.getListeningPort());
    timer.schedule(sweeper, 0, ccConfig.getHeartbeatPeriod());
    jobLog.open();
    startApplication();
    datasetDirectoryService.init(executor);
    workQueue.start();
    connectNCs();
    LOGGER.log(Level.INFO, "Started ClusterControllerService");
    notifyApplication();
}
Also used : IIPCI(org.apache.hyracks.ipc.api.IIPCI) ClusterControllerInfo(org.apache.hyracks.api.client.ClusterControllerInfo) JavaSerializationBasedPayloadSerializerDeserializer(org.apache.hyracks.ipc.impl.JavaSerializationBasedPayloadSerializerDeserializer) ServerContext(org.apache.hyracks.control.common.context.ServerContext) WebServer(org.apache.hyracks.control.cc.web.WebServer) InetSocketAddress(java.net.InetSocketAddress) JavaSerializationBasedPayloadSerializerDeserializer(org.apache.hyracks.ipc.impl.JavaSerializationBasedPayloadSerializerDeserializer) LogFile(org.apache.hyracks.control.common.logs.LogFile) File(java.io.File) IPCSystem(org.apache.hyracks.ipc.impl.IPCSystem)

Example 3 with IPCSystem

use of org.apache.hyracks.ipc.impl.IPCSystem in project asterixdb by apache.

the class NodeControllerService method start.

@Override
public void start() throws Exception {
    LOGGER.log(Level.INFO, "Starting NodeControllerService");
    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info("Setting uncaught exception handler " + getLifeCycleComponentManager());
    }
    Thread.currentThread().setUncaughtExceptionHandler(getLifeCycleComponentManager());
    Runtime.getRuntime().addShutdownHook(new NCShutdownHook(this));
    ipc = new IPCSystem(new InetSocketAddress(ncConfig.getClusterListenAddress(), ncConfig.getClusterListenPort()), 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);
    netManager.start();
    startApplication();
    init();
    datasetNetworkManager.start();
    if (messagingNetManager != null) {
        messagingNetManager.start();
    }
    IIPCHandle ccIPCHandle = ipc.getHandle(new InetSocketAddress(ncConfig.getClusterAddress(), ncConfig.getClusterPort()), ncConfig.getClusterConnectRetries());
    this.ccs = new ClusterControllerRemoteProxy(ccIPCHandle);
    HeartbeatSchema.GarbageCollectorInfo[] gcInfos = new HeartbeatSchema.GarbageCollectorInfo[gcMXBeans.size()];
    for (int i = 0; i < gcInfos.length; ++i) {
        gcInfos[i] = new HeartbeatSchema.GarbageCollectorInfo(gcMXBeans.get(i).getName());
    }
    HeartbeatSchema hbSchema = new HeartbeatSchema(gcInfos);
    // Use "public" versions of network addresses and ports
    NetworkAddress datasetAddress = datasetNetworkManager.getPublicNetworkAddress();
    NetworkAddress netAddress = netManager.getPublicNetworkAddress();
    NetworkAddress meesagingPort = messagingNetManager != null ? messagingNetManager.getPublicNetworkAddress() : null;
    int allCores = osMXBean.getAvailableProcessors();
    ccs.registerNode(new NodeRegistration(ipc.getSocketAddress(), id, ncConfig, netAddress, datasetAddress, osMXBean.getName(), osMXBean.getArch(), osMXBean.getVersion(), allCores, runtimeMXBean.getVmName(), runtimeMXBean.getVmVersion(), runtimeMXBean.getVmVendor(), runtimeMXBean.getClassPath(), runtimeMXBean.getLibraryPath(), runtimeMXBean.getBootClassPath(), runtimeMXBean.getInputArguments(), runtimeMXBean.getSystemProperties(), hbSchema, meesagingPort, application.getCapacity(), PidHelper.getPid()));
    synchronized (this) {
        while (registrationPending) {
            wait();
        }
    }
    if (registrationException != null) {
        throw registrationException;
    }
    serviceCtx.setDistributedState(nodeParameters.getDistributedState());
    workQueue.start();
    heartbeatTask = new HeartbeatTask(ccs);
    // Use reflection to set the priority of the timer thread.
    Field threadField = timer.getClass().getDeclaredField("thread");
    threadField.setAccessible(true);
    // The internal timer thread of the Timer object.
    Thread timerThread = (Thread) threadField.get(timer);
    timerThread.setPriority(Thread.MAX_PRIORITY);
    // Schedule heartbeat generator.
    timer.schedule(heartbeatTask, 0, nodeParameters.getHeartbeatPeriod());
    if (nodeParameters.getProfileDumpPeriod() > 0) {
        // Schedule profile dump generator.
        timer.schedule(new ProfileDumpTask(ccs), 0, nodeParameters.getProfileDumpPeriod());
    }
    LOGGER.log(Level.INFO, "Started NodeControllerService");
    application.startupCompleted();
}
Also used : IIPCHandle(org.apache.hyracks.ipc.api.IIPCHandle) NodeRegistration(org.apache.hyracks.control.common.controllers.NodeRegistration) PartitionManager(org.apache.hyracks.control.nc.partitions.PartitionManager) DatasetPartitionManager(org.apache.hyracks.control.nc.dataset.DatasetPartitionManager) IDatasetPartitionManager(org.apache.hyracks.api.dataset.IDatasetPartitionManager) InetSocketAddress(java.net.InetSocketAddress) IPCSystem(org.apache.hyracks.ipc.impl.IPCSystem) ClusterControllerRemoteProxy(org.apache.hyracks.control.common.ipc.ClusterControllerRemoteProxy) Field(java.lang.reflect.Field) NetworkAddress(org.apache.hyracks.api.comm.NetworkAddress) DatasetNetworkManager(org.apache.hyracks.control.nc.net.DatasetNetworkManager) MessagingNetworkManager(org.apache.hyracks.control.nc.net.MessagingNetworkManager) NetworkManager(org.apache.hyracks.control.nc.net.NetworkManager) HeartbeatSchema(org.apache.hyracks.control.common.heartbeat.HeartbeatSchema)

Example 4 with IPCSystem

use of org.apache.hyracks.ipc.impl.IPCSystem in project asterixdb by apache.

the class IPCTest method createServerIPCSystem.

private IPCSystem createServerIPCSystem() throws IOException {
    final Executor executor = Executors.newCachedThreadPool();
    IIPCI ipci = new IIPCI() {

        @Override
        public void deliverIncomingMessage(final IIPCHandle handle, final long mid, long rmid, final Object payload, Exception exception) {
            executor.execute(new Runnable() {

                @Override
                public void run() {
                    Object result = null;
                    Exception exception = null;
                    try {
                        Integer i = (Integer) payload;
                        result = i.intValue() * 2;
                    } catch (Exception e) {
                        exception = e;
                    }
                    try {
                        handle.send(mid, result, exception);
                    } catch (IPCException e) {
                        e.printStackTrace();
                    }
                }
            });
        }
    };
    return new IPCSystem(new InetSocketAddress("127.0.0.1", 0), ipci, new JavaSerializationBasedPayloadSerializerDeserializer());
}
Also used : IIPCHandle(org.apache.hyracks.ipc.api.IIPCHandle) IIPCI(org.apache.hyracks.ipc.api.IIPCI) Executor(java.util.concurrent.Executor) JavaSerializationBasedPayloadSerializerDeserializer(org.apache.hyracks.ipc.impl.JavaSerializationBasedPayloadSerializerDeserializer) InetSocketAddress(java.net.InetSocketAddress) IPCException(org.apache.hyracks.ipc.exceptions.IPCException) IOException(java.io.IOException) IPCException(org.apache.hyracks.ipc.exceptions.IPCException) IPCSystem(org.apache.hyracks.ipc.impl.IPCSystem)

Aggregations

InetSocketAddress (java.net.InetSocketAddress)4 IPCSystem (org.apache.hyracks.ipc.impl.IPCSystem)4 IIPCHandle (org.apache.hyracks.ipc.api.IIPCHandle)3 IOException (java.io.IOException)2 IIPCI (org.apache.hyracks.ipc.api.IIPCI)2 IPCException (org.apache.hyracks.ipc.exceptions.IPCException)2 JavaSerializationBasedPayloadSerializerDeserializer (org.apache.hyracks.ipc.impl.JavaSerializationBasedPayloadSerializerDeserializer)2 File (java.io.File)1 Field (java.lang.reflect.Field)1 Executor (java.util.concurrent.Executor)1 ClusterControllerInfo (org.apache.hyracks.api.client.ClusterControllerInfo)1 NetworkAddress (org.apache.hyracks.api.comm.NetworkAddress)1 IDatasetPartitionManager (org.apache.hyracks.api.dataset.IDatasetPartitionManager)1 WebServer (org.apache.hyracks.control.cc.web.WebServer)1 ServerContext (org.apache.hyracks.control.common.context.ServerContext)1 NodeRegistration (org.apache.hyracks.control.common.controllers.NodeRegistration)1 HeartbeatSchema (org.apache.hyracks.control.common.heartbeat.HeartbeatSchema)1 ClusterControllerRemoteProxy (org.apache.hyracks.control.common.ipc.ClusterControllerRemoteProxy)1 LogFile (org.apache.hyracks.control.common.logs.LogFile)1 DatasetPartitionManager (org.apache.hyracks.control.nc.dataset.DatasetPartitionManager)1