Search in sources :

Example 1 with ProxyServiceImpl

use of com.hazelcast.spi.impl.proxyservice.impl.ProxyServiceImpl in project hazelcast by hazelcast.

the class PostJoinProxyOperation method run.

@Override
public void run() throws Exception {
    if (proxies == null || proxies.size() <= 0) {
        return;
    }
    NodeEngine nodeEngine = getNodeEngine();
    ProxyServiceImpl proxyService = getService();
    ExecutionService executionService = nodeEngine.getExecutionService();
    for (final ProxyInfo proxy : proxies) {
        final ProxyRegistry registry = proxyService.getOrCreateRegistry(proxy.getServiceName());
        try {
            executionService.execute(ExecutionService.SYSTEM_EXECUTOR, new Runnable() {

                @Override
                public void run() {
                    registry.createProxy(proxy.getObjectName(), false, true);
                }
            });
        } catch (Throwable t) {
            getLogger().warning("Cannot create proxy [" + proxy.getServiceName() + ":" + proxy.getObjectName() + "]!", t);
        }
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) ProxyInfo(com.hazelcast.spi.impl.proxyservice.impl.ProxyInfo) ProxyRegistry(com.hazelcast.spi.impl.proxyservice.impl.ProxyRegistry) ProxyServiceImpl(com.hazelcast.spi.impl.proxyservice.impl.ProxyServiceImpl) ExecutionService(com.hazelcast.spi.ExecutionService)

Example 2 with ProxyServiceImpl

use of com.hazelcast.spi.impl.proxyservice.impl.ProxyServiceImpl in project hazelcast by hazelcast.

the class DistributedObjectDestroyOperation method run.

@Override
public void run() throws Exception {
    ProxyServiceImpl proxyService = getService();
    proxyService.destroyLocalDistributedObject(serviceName, name, false);
}
Also used : ProxyServiceImpl(com.hazelcast.spi.impl.proxyservice.impl.ProxyServiceImpl)

Example 3 with ProxyServiceImpl

use of com.hazelcast.spi.impl.proxyservice.impl.ProxyServiceImpl in project hazelcast by hazelcast.

the class DistributedObjectTest method testInitialization_whenEachNodeExecutesPostJoinOperations.

@Test
public void testInitialization_whenEachNodeExecutesPostJoinOperations() {
    int nodeCount = 4;
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(nodeCount);
    Config config = new Config();
    config.getServicesConfig().addServiceConfig(new ServiceConfig().setImplementation(new TestInitializingObjectService()).setEnabled(true).setName(TestInitializingObjectService.NAME));
    String serviceName = TestInitializingObjectService.NAME;
    String objectName = "test-object";
    HazelcastInstance[] instances = new HazelcastInstance[nodeCount];
    for (int i = 0; i < instances.length; i++) {
        instances[i] = factory.newHazelcastInstance(config);
        instances[i].getDistributedObject(serviceName, objectName);
    }
    for (int i = 0; i < nodeCount; i++) {
        Node node = TestUtil.getNode(instances[i]);
        ProxyServiceImpl proxyService = (ProxyServiceImpl) node.nodeEngine.getProxyService();
        Operation postJoinOperation = proxyService.getPostJoinOperation();
        for (int j = 0; j < nodeCount; j++) {
            if (i == j)
                continue;
            Node node2 = TestUtil.getNode(instances[j]);
            node.nodeEngine.getOperationService().send(postJoinOperation, node2.address);
        }
    }
    for (HazelcastInstance instance : instances) {
        TestInitializingObject obj = instance.getDistributedObject(serviceName, objectName);
        assertTrue(obj.init.get());
        assertFalse(obj.error);
    }
}
Also used : ServiceConfig(com.hazelcast.config.ServiceConfig) Config(com.hazelcast.config.Config) ServiceConfig(com.hazelcast.config.ServiceConfig) Node(com.hazelcast.instance.Node) Operation(com.hazelcast.spi.Operation) ProxyServiceImpl(com.hazelcast.spi.impl.proxyservice.impl.ProxyServiceImpl) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 4 with ProxyServiceImpl

use of com.hazelcast.spi.impl.proxyservice.impl.ProxyServiceImpl in project hazelcast by hazelcast.

the class Node method initializeListeners.

@SuppressWarnings({ "checkstyle:npathcomplexity", "checkstyle:cyclomaticcomplexity" })
private void initializeListeners(Config config) {
    for (final ListenerConfig listenerCfg : config.getListenerConfigs()) {
        Object listener = listenerCfg.getImplementation();
        if (listener == null) {
            try {
                listener = ClassLoaderUtil.newInstance(configClassLoader, listenerCfg.getClassName());
            } catch (Exception e) {
                logger.severe(e);
            }
        }
        if (listener instanceof HazelcastInstanceAware) {
            ((HazelcastInstanceAware) listener).setHazelcastInstance(hazelcastInstance);
        }
        boolean known = false;
        if (listener instanceof DistributedObjectListener) {
            final ProxyServiceImpl proxyService = (ProxyServiceImpl) nodeEngine.getProxyService();
            proxyService.addProxyListener((DistributedObjectListener) listener);
            known = true;
        }
        if (listener instanceof MembershipListener) {
            clusterService.addMembershipListener((MembershipListener) listener);
            known = true;
        }
        if (listener instanceof MigrationListener) {
            partitionService.addMigrationListener((MigrationListener) listener);
            known = true;
        }
        if (listener instanceof PartitionLostListener) {
            partitionService.addPartitionLostListener((PartitionLostListener) listener);
            known = true;
        }
        if (listener instanceof LifecycleListener) {
            hazelcastInstance.lifecycleService.addLifecycleListener((LifecycleListener) listener);
            known = true;
        }
        if (listener instanceof ClientListener) {
            String serviceName = ClientEngineImpl.SERVICE_NAME;
            nodeEngine.getEventService().registerLocalListener(serviceName, serviceName, listener);
            known = true;
        }
        if (listener instanceof InternalMigrationListener) {
            final InternalPartitionServiceImpl partitionService = (InternalPartitionServiceImpl) nodeEngine.getPartitionService();
            partitionService.setInternalMigrationListener((InternalMigrationListener) listener);
            known = true;
        }
        if (nodeExtension.registerListener(listener)) {
            known = true;
        }
        if (listener != null && !known) {
            final String error = "Unknown listener type: " + listener.getClass();
            Throwable t = new IllegalArgumentException(error);
            logger.warning(error, t);
        }
    }
}
Also used : InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) InternalMigrationListener(com.hazelcast.internal.partition.impl.InternalMigrationListener) LifecycleListener(com.hazelcast.core.LifecycleListener) HazelcastInstanceAware(com.hazelcast.core.HazelcastInstanceAware) DistributedObjectListener(com.hazelcast.core.DistributedObjectListener) ProxyServiceImpl(com.hazelcast.spi.impl.proxyservice.impl.ProxyServiceImpl) ClientListener(com.hazelcast.core.ClientListener) ListenerConfig(com.hazelcast.config.ListenerConfig) PartitionLostListener(com.hazelcast.partition.PartitionLostListener) MembershipListener(com.hazelcast.core.MembershipListener) MigrationListener(com.hazelcast.core.MigrationListener) InternalMigrationListener(com.hazelcast.internal.partition.impl.InternalMigrationListener)

Aggregations

ProxyServiceImpl (com.hazelcast.spi.impl.proxyservice.impl.ProxyServiceImpl)4 Config (com.hazelcast.config.Config)1 ListenerConfig (com.hazelcast.config.ListenerConfig)1 ServiceConfig (com.hazelcast.config.ServiceConfig)1 ClientListener (com.hazelcast.core.ClientListener)1 DistributedObjectListener (com.hazelcast.core.DistributedObjectListener)1 HazelcastInstanceAware (com.hazelcast.core.HazelcastInstanceAware)1 LifecycleListener (com.hazelcast.core.LifecycleListener)1 MembershipListener (com.hazelcast.core.MembershipListener)1 MigrationListener (com.hazelcast.core.MigrationListener)1 Node (com.hazelcast.instance.Node)1 InternalMigrationListener (com.hazelcast.internal.partition.impl.InternalMigrationListener)1 InternalPartitionServiceImpl (com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl)1 PartitionLostListener (com.hazelcast.partition.PartitionLostListener)1 ExecutionService (com.hazelcast.spi.ExecutionService)1 NodeEngine (com.hazelcast.spi.NodeEngine)1 Operation (com.hazelcast.spi.Operation)1 ProxyInfo (com.hazelcast.spi.impl.proxyservice.impl.ProxyInfo)1 ProxyRegistry (com.hazelcast.spi.impl.proxyservice.impl.ProxyRegistry)1 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)1