private ClientExceptions initClientExceptionFactory() { boolean jcacheAvailable = JCacheDetector.isJCacheAvailable(nodeEngine.getConfigClassLoader()); return new ClientExceptions(jcacheAvailable); }
private ClientExceptions initClientExceptionFactory() { boolean jcacheAvailable = JCacheDetector.isJCacheAvailable(nodeEngine.getConfigClassLoader()); return new ClientExceptions(jcacheAvailable); }
@SuppressWarnings("unchecked") private Object createServiceObject(String className) { try { ClassLoader classLoader = nodeEngine.getConfigClassLoader(); Class serviceClass = ClassLoaderUtil.loadClass(classLoader, className); try { Constructor constructor = serviceClass.getConstructor(NodeEngine.class); return constructor.newInstance(nodeEngine); } catch (NoSuchMethodException ignored) { ignore(ignored); } final Constructor constructor = serviceClass.getDeclaredConstructor(); if (!constructor.isAccessible()) { constructor.setAccessible(true); } return constructor.newInstance(); } catch (Exception e) { logger.severe(e); } return null; }
@SuppressWarnings("unchecked") private Object createServiceObject(String className) { try { ClassLoader classLoader = nodeEngine.getConfigClassLoader(); Class serviceClass = ClassLoaderUtil.loadClass(classLoader, className); try { Constructor constructor = serviceClass.getConstructor(NodeEngine.class); return constructor.newInstance(nodeEngine); } catch (NoSuchMethodException ignored) { ignore(ignored); } final Constructor constructor = serviceClass.getDeclaredConstructor(); if (!constructor.isAccessible()) { constructor.setAccessible(true); } return constructor.newInstance(); } catch (Exception e) { logger.severe(e); } return null; }
private ManagedExecutorService createExecutor(String name, int poolSize, int queueCapacity, ExecutorType type) { ManagedExecutorService executor; if (type == ExecutorType.CACHED) { executor = new CachedExecutorServiceDelegate(nodeEngine, name, cachedExecutorService, poolSize, queueCapacity); } else if (type == ExecutorType.CONCRETE) { ClassLoader classLoader = nodeEngine.getConfigClassLoader(); String hzName = nodeEngine.getHazelcastInstance().getName(); String internalName = name.startsWith("hz:") ? name.substring(BEGIN_INDEX) : name; String threadNamePrefix = createThreadPoolName(hzName, internalName); PoolExecutorThreadFactory threadFactory = new PoolExecutorThreadFactory(threadNamePrefix, classLoader); NamedThreadPoolExecutor pool = new NamedThreadPoolExecutor(name, poolSize, poolSize, KEEP_ALIVE_TIME, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(queueCapacity), threadFactory ); pool.allowCoreThreadTimeOut(true); executor = pool; } else { throw new IllegalArgumentException("Unknown executor type: " + type); } return executor; }
private ManagedExecutorService createExecutor(String name, int poolSize, int queueCapacity, ExecutorType type) { ManagedExecutorService executor; if (type == ExecutorType.CACHED) { executor = new CachedExecutorServiceDelegate(nodeEngine, name, cachedExecutorService, poolSize, queueCapacity); } else if (type == ExecutorType.CONCRETE) { ClassLoader classLoader = nodeEngine.getConfigClassLoader(); String hzName = nodeEngine.getHazelcastInstance().getName(); String internalName = name.startsWith("hz:") ? name.substring(BEGIN_INDEX) : name; String threadNamePrefix = createThreadPoolName(hzName, internalName); PoolExecutorThreadFactory threadFactory = new PoolExecutorThreadFactory(threadNamePrefix, classLoader); NamedThreadPoolExecutor pool = new NamedThreadPoolExecutor(name, poolSize, poolSize, KEEP_ALIVE_TIME, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(queueCapacity), threadFactory ); pool.allowCoreThreadTimeOut(true); executor = pool; } else { throw new IllegalArgumentException("Unknown executor type: " + type); } return executor; }
private void registerCacheServiceIfAvailable() { // optional initialization for CacheService when JCache API is on classpath if (JCacheDetector.isJCacheAvailable(nodeEngine.getConfigClassLoader(), logger)) { ICacheService service = createService(ICacheService.class); registerService(ICacheService.SERVICE_NAME, service); } else { logger.finest("javax.cache api is not detected on classpath. Skipping CacheService..."); } }
private void registerCacheServiceIfAvailable() { // optional initialization for CacheService when JCache API is on classpath if (JCacheDetector.isJCacheAvailable(nodeEngine.getConfigClassLoader(), logger)) { ICacheService service = createService(ICacheService.class); registerService(ICacheService.SERVICE_NAME, service); } else { logger.finest("javax.cache api is not detected on classpath. Skipping CacheService..."); } }
private void initializeListenerInternal(String instanceName, QuorumListenerConfig listenerConfig) { QuorumListener listener = null; if (listenerConfig.getImplementation() != null) { listener = listenerConfig.getImplementation(); } else if (listenerConfig.getClassName() != null) { try { listener = ClassLoaderUtil .newInstance(nodeEngine.getConfigClassLoader(), listenerConfig.getClassName()); } catch (Exception e) { throw ExceptionUtil.rethrow(e); } } if (listener != null) { addQuorumListener(instanceName, listener); } }
private void initializeListenerInternal(String instanceName, QuorumListenerConfig listenerConfig) { QuorumListener listener = null; if (listenerConfig.getImplementation() != null) { listener = listenerConfig.getImplementation(); } else if (listenerConfig.getClassName() != null) { try { listener = ClassLoaderUtil .newInstance(nodeEngine.getConfigClassLoader(), listenerConfig.getClassName()); } catch (Exception e) { throw ExceptionUtil.rethrow(e); } } if (listener != null) { addQuorumListener(instanceName, listener); } }
private QuorumFunction initializeQuorumFunction() { QuorumFunction quorumFunction = config.getQuorumFunctionImplementation(); if (quorumFunction == null && config.getQuorumFunctionClassName() != null) { try { quorumFunction = newInstance(nodeEngine.getConfigClassLoader(), config.getQuorumFunctionClassName()); } catch (Exception e) { throw rethrow(e); } } if (quorumFunction == null) { quorumFunction = new MemberCountQuorumFunction(size); } ManagedContext managedContext = nodeEngine.getSerializationService().getManagedContext(); quorumFunction = (QuorumFunction) managedContext.initialize(quorumFunction); return quorumFunction; }
private QuorumFunction initializeQuorumFunction() { QuorumFunction quorumFunction = config.getQuorumFunctionImplementation(); if (quorumFunction == null && config.getQuorumFunctionClassName() != null) { try { quorumFunction = newInstance(nodeEngine.getConfigClassLoader(), config.getQuorumFunctionClassName()); } catch (Exception e) { throw rethrow(e); } } if (quorumFunction == null) { quorumFunction = new MemberCountQuorumFunction(size); } ManagedContext managedContext = nodeEngine.getSerializationService().getManagedContext(); quorumFunction = (QuorumFunction) managedContext.initialize(quorumFunction); return quorumFunction; }
TaskPollThread() { super(createThreadName(instance.getName(), "MC.Task.Poller")); register(new ThreadDumpRequest()); register(new ExecuteScriptRequest()); register(new ConsoleCommandRequest()); register(new RunGcRequest()); register(new GetMapEntryRequest()); if (JCacheDetector.isJCacheAvailable(instance.node.getNodeEngine().getConfigClassLoader(), logger)) { register(new GetCacheEntryRequest()); } else { logger.finest("javax.cache api is not detected on classpath.Skip registering GetCacheEntryRequest..."); } register(new TriggerPartialStartRequest()); registerConfigRequests(); registerClusterManagementRequests(); registerWanRequests(); }
TaskPollThread() { super(createThreadName(instance.getName(), "MC.Task.Poller")); register(new ThreadDumpRequest()); register(new ExecuteScriptRequest()); register(new ConsoleCommandRequest()); register(new RunGcRequest()); register(new GetMapEntryRequest()); if (JCacheDetector.isJCacheAvailable(instance.node.getNodeEngine().getConfigClassLoader(), logger)) { register(new GetCacheEntryRequest()); } else { logger.finest("javax.cache api is not detected on classpath.Skip registering GetCacheEntryRequest..."); } register(new TriggerPartialStartRequest()); registerConfigRequests(); registerClusterManagementRequests(); registerWanRequests(); }