Java 类com.hazelcast.config.ExecutorConfig 实例源码

项目:concursus    文件:HazelcastCommandExecutorConfiguration.java   
/**
 * Add configuration to the supplied {@link Config} to support the use of a {@link HazelcastCommandExecutor}.
 * @param config The {@link Config} to configure.
 * @return The updated {@link Config}.
 */
public Config addCommandExecutorConfiguration(Config config) {
    SerializerConfig serializerConfig = new SerializerConfig()
            .setImplementation(RemoteCommandSerialiser.using(
                    objectMapper,
                    CommandTypeMatcher.matchingAgainst(typeInfoMap)))
            .setTypeClass(RemoteCommand.class);

    ManagedContext managedContext = CommandProcessingManagedContext
            .processingCommandsWith(dispatchingCommandProcessor);

    config.getSerializationConfig().addSerializerConfig(serializerConfig);

    config.setManagedContext(config.getManagedContext() == null
            ? managedContext
            : CompositeManagedContext.of(managedContext, config.getManagedContext()));

    config.addExecutorConfig(new ExecutorConfig(executorName, threadsPerNode));
    return config;
}
项目:hz-executor    文件:Test7.java   
private static Config createConfig(String name) {
    Config config = new Config(name);

    ExecutorConfig executorConfig = config.getExecutorConfig(EXECUTOR_NAME);
    executorConfig.setPoolSize(10);
    executorConfig.setQueueCapacity(10000);

    // map without backup

    MapConfig mapConfig1 = config.getMapConfig(MAP1_NAME);
    mapConfig1.setBackupCount(0);

    MapConfig mapConfig2 = config.getMapConfig(MAP2_NAME);
    mapConfig2.setBackupCount(0);

    return config;
}
项目:hz-executor    文件:Test6.java   
private static Config createConfig(String name) {
    Config config = new Config(name);

    ExecutorConfig executorConfig = config.getExecutorConfig(EXECUTOR_NAME);
    executorConfig.setPoolSize(10);
    executorConfig.setQueueCapacity(10000);

    // map without backup

    MapConfig mapConfig1 = config.getMapConfig(MAP1_NAME);
    mapConfig1.setBackupCount(0);

    MapConfig mapConfig2 = config.getMapConfig(MAP2_NAME);
    mapConfig2.setBackupCount(0);

    return config;
}
项目:hazelcast-archive    文件:ExecutorManager.java   
private NamedExecutorService getOrCreateNamedExecutorService(String name, GroupProperties.GroupProperty groupProperty) {
    NamedExecutorService namedExecutorService = mapExecutors.get(name);
    if (namedExecutorService == null) {
        synchronized (CREATE_LOCK) {
            namedExecutorService = mapExecutors.get(name);
            if (namedExecutorService == null) {
                ExecutorConfig executorConfig = node.getConfig().getExecutorConfig(name.substring(2));
                if (groupProperty != null) {
                    executorConfig.setCorePoolSize(groupProperty.getInteger());
                    executorConfig.setMaxPoolSize(groupProperty.getInteger());
                }
                namedExecutorService = newNamedExecutorService(name, executorConfig);
            }
        }
    }
    return namedExecutorService;
}
项目:health-and-care-developer-network    文件:ExecutorManager.java   
private NamedExecutorService getOrCreateNamedExecutorService(String name, GroupProperties.GroupProperty groupProperty) {
    NamedExecutorService namedExecutorService = mapExecutors.get(name);
    if (namedExecutorService == null) {
        synchronized (CREATE_LOCK) {
            namedExecutorService = mapExecutors.get(name);
            if (namedExecutorService == null) {
                ExecutorConfig executorConfig = node.getConfig().getExecutorConfig(name.substring(2));
                if (groupProperty != null) {
                    executorConfig.setCorePoolSize(groupProperty.getInteger());
                    executorConfig.setMaxPoolSize(groupProperty.getInteger());
                }
                namedExecutorService = newNamedExecutorService(name, executorConfig);
            }
        }
    }
    return namedExecutorService;
}
项目:hazelcast-archive    文件:ExecutorManager.java   
private NamedExecutorService newNamedExecutorService(String name, ExecutorConfig executorConfig) {
    logger.log(Level.FINEST, "creating new named executor service " + name);
    int concurrencyLevel = executorConfig.getMaxPoolSize();
    ParallelExecutor parallelExecutor = parallelExecutorService.newParallelExecutor(concurrencyLevel);
    NamedExecutorService es = new NamedExecutorService(name, parallelExecutor);
    mapExecutors.put(name, es);
    return es;
}
项目:spring-open    文件:HazelcastCLI.java   
/**
 * {@link TestApp} modified to read conf/hazelcast.xml.
 *
 * @param args none expected
 * @throws Exception exception
 */
public static void main(String[] args) throws Exception {
    final String configFilename = System.getProperty(
            "net.onrc.onos.core.datagrid.HazelcastDatagrid.datagridConfig",
            "conf/hazelcast.xml");
    Config config = HazelcastDatagrid.loadHazelcastConfig(configFilename);

    for (int k = 1; k <= LOAD_EXECUTORS_COUNT; k++) {
        config.addExecutorConfig(new ExecutorConfig("e" + k).setPoolSize(k));
    }

    HazelcastCLI cli = new HazelcastCLI(Hazelcast.getOrCreateHazelcastInstance(config));
    cli.start(args);
}
项目:health-and-care-developer-network    文件:ExecutorManager.java   
ExecutorManager(final Node node) {
    super(node);
    logger.log(Level.FINEST, "Starting ExecutorManager");
    GroupProperties gp = node.groupProperties;
    ClassLoader classLoader = node.getConfig().getClassLoader();
    threadPoolExecutor = new ThreadPoolExecutor(
            5, Integer.MAX_VALUE,
            60L,
            TimeUnit.SECONDS,
            new SynchronousQueue(),
            new ExecutorThreadFactory(node.threadGroup, node.getThreadPoolNamePrefix("cached"), classLoader),
            new RejectionHandler()) {
        protected void beforeExecute(Thread t, Runnable r) {
            threadPoolBeforeExecute(t, r);
        }
    };
    esScheduled = new ScheduledThreadPoolExecutor(3, new ExecutorThreadFactory(node.threadGroup,
            node.getThreadPoolNamePrefix("scheduled"), classLoader), new RejectionHandler()) {
        protected void beforeExecute(Thread t, Runnable r) {
            threadPoolBeforeExecute(t, r);
        }
    };
    parallelExecutorService = new ParallelExecutorService(node.getLogger(ParallelExecutorService.class.getName()), threadPoolExecutor);
    defaultExecutorService = getOrCreateNamedExecutorService(DEFAULT_EXECUTOR_SERVICE);
    queryExecutorService = getOrCreateNamedExecutorService(QUERY_EXECUTOR_SERVICE, gp.EXECUTOR_QUERY_THREAD_COUNT);
    eventExecutorService = getOrCreateNamedExecutorService(EVENT_EXECUTOR_SERVICE, gp.EXECUTOR_EVENT_THREAD_COUNT);
    mapLoaderExecutorService = parallelExecutorService.newParallelExecutor(gp.MAP_LOAD_THREAD_COUNT.getInteger());
    asyncExecutorService = parallelExecutorService.newBlockingParallelExecutor(24, 1000);
    newNamedExecutorService(Prefix.EXECUTOR_SERVICE + "hz.initialization", new ExecutorConfig("hz.initialization",
            Integer.MAX_VALUE, Integer.MAX_VALUE, 60));
    registerPacketProcessor(EXECUTE, new ExecutionOperationHandler());
    registerPacketProcessor(CANCEL_EXECUTION, new ExecutionCancelOperationHandler());
    started = true;
}
项目:health-and-care-developer-network    文件:ExecutorManager.java   
private NamedExecutorService newNamedExecutorService(String name, ExecutorConfig executorConfig) {
    logger.log(Level.FINEST, "creating new named executor service " + name);
    int concurrencyLevel = executorConfig.getMaxPoolSize();
    ParallelExecutor parallelExecutor = parallelExecutorService.newParallelExecutor(concurrencyLevel);
    NamedExecutorService es = new NamedExecutorService(name, parallelExecutor);
    mapExecutors.put(name, es);
    return es;
}
项目:apgas    文件:Transport.java   
/**
 * Initializes the {@link HazelcastInstance} for this global runtime instance.
 *
 * @param runtime
 *          the global runtime instance
 * @param master
 *          member to connect to or null
 * @param localhost
 *          the preferred ip address of this host or null
 * @param compact
 *          reduce thread creation if set
 * @param kryo
 *          use kryo serialization if set
 */
protected Transport(GlobalRuntimeImpl runtime, String master,
    String localhost, boolean compact, boolean kryo) {
  this.runtime = runtime;
  // config
  final Config config = new Config();
  config.setProperty("hazelcast.logging.type", "none");
  config.setProperty("hazelcast.wait.seconds.before.join", "0");
  config.setProperty("hazelcast.socket.connect.timeout.seconds", "1");
  config.setProperty("hazelcast.connection.monitor.max.faults", "0");
  if (compact) {
    config.setProperty("hazelcast.operation.thread.count", "2");
    config.setProperty("hazelcast.operation.generic.thread.count", "2");
    config.setProperty("hazelcast.io.thread.count", "2");
    config.setProperty("hazelcast.event.thread.count", "2");
    config.addExecutorConfig(
        new ExecutorConfig(ExecutionService.ASYNC_EXECUTOR, 2));
    config.addExecutorConfig(
        new ExecutorConfig(ExecutionService.SYSTEM_EXECUTOR, 2));
    config.addExecutorConfig(
        new ExecutorConfig(ExecutionService.SCHEDULED_EXECUTOR, 2));
  }

  // kryo
  if (kryo) {
    config.getSerializationConfig().addSerializerConfig(
        new SerializerConfig().setTypeClass(SerializableRunnable.class)
            .setImplementation(new KryoSerializer()));
  }

  config.addMapConfig(
      new MapConfig(APGAS_FINISH).setInMemoryFormat(InMemoryFormat.OBJECT));

  // join config
  final JoinConfig join = config.getNetworkConfig().getJoin();
  join.getMulticastConfig().setEnabled(false);
  join.getTcpIpConfig().setEnabled(true);
  if (localhost != null) {
    System.setProperty("hazelcast.local.localAddress", localhost);
  }
  if (master != null) {
    join.getTcpIpConfig().addMember(master);
  }
  config.setInstanceName(APGAS);

  hazelcast = Hazelcast.newHazelcastInstance(config);
  me = hazelcast.getCluster().getLocalMember();

  allMembers = hazelcast.getList(APGAS_PLACES);
  allMembers.add(me);
  int id = 0;
  for (final Member member : allMembers) {
    if (member.getUuid().equals(me.getUuid())) {
      break;
    }
    ++id;
  }
  here = id;

  executor = hazelcast.getExecutorService(APGAS_EXECUTOR);
}
项目:hz-executor    文件:Test2.java   
private static Config createConfig(String name) {
    Config config = new Config(name);

    ExecutorConfig executorConfig = config.getExecutorConfig(EXECUTOR_NAME);
    executorConfig.setPoolSize(10);

    // map without backup

    MapConfig mapConfig1 = config.getMapConfig(MAP1_NAME);
    mapConfig1.setBackupCount(0);

    MapConfig mapConfig2 = config.getMapConfig(MAP2_NAME);
    mapConfig2.setBackupCount(0);

    return config;
}
项目:hz-executor    文件:Test4.java   
private static Config createConfig(String name) {
    Config config = new Config(name);

    ExecutorConfig executorConfig = config.getExecutorConfig(EXECUTOR_NAME);
    executorConfig.setPoolSize(10);

    // map without backup

    MapConfig mapConfig1 = config.getMapConfig(MAP1_NAME);
    mapConfig1.setBackupCount(0);

    MapConfig mapConfig2 = config.getMapConfig(MAP2_NAME);
    mapConfig2.setBackupCount(0);

    return config;
}
项目:hz-executor    文件:Test3.java   
private static Config createConfig(String name) {
    Config config = new Config(name);

    ExecutorConfig executorConfig = config.getExecutorConfig(EXECUTOR_NAME);
    executorConfig.setPoolSize(10);

    // map without backup

    MapConfig mapConfig1 = config.getMapConfig(MAP1_NAME);
    mapConfig1.setBackupCount(0);

    MapConfig mapConfig2 = config.getMapConfig(MAP2_NAME);
    mapConfig2.setBackupCount(0);

    return config;
}
项目:hz-executor    文件:Test5.java   
private static Config createConfig(String name) {
    Config config = new Config(name);

    ExecutorConfig executorConfig = config.getExecutorConfig(EXECUTOR_NAME);
    executorConfig.setPoolSize(10);

    // map without backup

    MapConfig mapConfig1 = config.getMapConfig(MAP1_NAME);
    mapConfig1.setBackupCount(0);

    MapConfig mapConfig2 = config.getMapConfig(MAP2_NAME);
    mapConfig2.setBackupCount(0);

    return config;
}
项目:gw2live    文件:HazelcastCache.java   
private HazelcastCache() {
    final AppConfig config = AppConfig.getInstance();
    final Map<String, MapConfig> mapconfigs = new HashMap<>();
    GroupConfig groupconfig = new GroupConfig();
    groupconfig.setName(config.getString("cluster.name", "gw2live"));
    groupconfig.setPassword(config.getString("cluster.password", "gw2live"));
    final MapConfig mapconfig = new MapConfig();
    mapconfig.getMaxSizeConfig().setMaxSizePolicy(MaxSizePolicy.PER_PARTITION);
    mapconfig.getMaxSizeConfig().setSize(0);
    mapconfig.setEvictionPolicy(MapConfig.DEFAULT_EVICTION_POLICY);
    mapconfig.setBackupCount(1);
    mapconfigs.put("*-cache", mapconfig);
    final NetworkConfig nwconfig = new NetworkConfig();
    if(config.containsKey("cluster.interface")) {
        final InterfacesConfig interfaces = new InterfacesConfig();
        interfaces.addInterface(config.getString("cluster.interface"));
        interfaces.setEnabled(true);
        nwconfig.setInterfaces(interfaces);
    }
    nwconfig.setPort(config.getInteger("cluster.port", 5801));
    nwconfig.setPortAutoIncrement(true);
    final MulticastConfig mcconfig = new MulticastConfig();
    mcconfig.setEnabled(true);
    mcconfig.setMulticastGroup(config.getString("cluster.multicast.group", "224.2.2.3"));
    mcconfig.setMulticastPort(config.getInteger("cluster.multicast.port", 58011));
    mcconfig.setMulticastTimeToLive(MulticastConfig.DEFAULT_MULTICAST_TTL);
    mcconfig.setMulticastTimeoutSeconds(MulticastConfig.DEFAULT_MULTICAST_TIMEOUT_SECONDS);
    final JoinConfig join = new JoinConfig();
    join.setMulticastConfig(mcconfig);
    nwconfig.setJoin(join);
    final ExecutorConfig execconfig = new ExecutorConfig();
    execconfig.setName("default");
    execconfig.setPoolSize(4);
    execconfig.setQueueCapacity(100);
    final Map<String, ExecutorConfig> execmap = new HashMap<>();
    execmap.put("default", execconfig);
    final Config hconfig = new Config();
    hconfig.setInstanceName("gw2live");
    hconfig.setGroupConfig(groupconfig);
    hconfig.setMapConfigs(mapconfigs);
    hconfig.setNetworkConfig(nwconfig);
    hconfig.setExecutorConfigs(execmap);
    hconfig.setProperty("hazelcast.shutdownhook.enabled", "false");
    hconfig.setProperty("hazelcast.wait.seconds.before.join", "0");
    hconfig.setProperty("hazelcast.rest.enabled", "false");
    hconfig.setProperty("hazelcast.memcache.enabled", "false");
    hconfig.setProperty("hazelcast.mancenter.enabled", "false");
    hconfig.setProperty("hazelcast.logging.type", "none");
    cache = Hazelcast.newHazelcastInstance(hconfig);

    LOG.debug("Hazelcast initialized");
}