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);
}
}
}
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);
}
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);
}
}
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);
}
}
}
Aggregations