本文整理汇总了Java中org.apache.ignite.configuration.IgniteConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java IgniteConfiguration类的具体用法?Java IgniteConfiguration怎么用?Java IgniteConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IgniteConfiguration类属于org.apache.ignite.configuration包,在下文中一共展示了IgniteConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: helloworldConfiguration
import org.apache.ignite.configuration.IgniteConfiguration; //导入依赖的package包/类
public static IgniteConfiguration helloworldConfiguration() {
int cpus = Runtime.getRuntime().availableProcessors();
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setIgniteInstanceName("hello-world");
cfg.setClientMode(true);
cfg.setPeerClassLoadingEnabled(true);
cfg.setDeploymentMode(DeploymentMode.CONTINUOUS);
cfg.setPeerClassLoadingMissedResourcesCacheSize(200);
cfg.setPublicThreadPoolSize(4 * cpus);
cfg.setSystemThreadPoolSize(2 * cpus);
// log frequency in ms
cfg.setMetricsLogFrequency(30000);
cfg.setGridLogger(igniteLogger());
cfg.setDiscoverySpi(multicastDiscoverySpi());
return cfg;
}
示例2: createIgnite
import org.apache.ignite.configuration.IgniteConfiguration; //导入依赖的package包/类
@Bean
@Scope("singleton")
@Qualifier("operationIgniteClient")
@ConditionalOnMissingBean(KafkaOperationRepository.class)
public Ignite createIgnite(ApplicationContext applicationContext) throws IgniteCheckedException {
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setClientMode(true);
cfg.setPeerClassLoadingEnabled(false);
TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
ipFinder.setAddresses(Arrays.asList(clientAddress.split(",")));
discoSpi.setIpFinder(ipFinder);
cfg.setDiscoverySpi(discoSpi);
cfg.setMetricsLogFrequency(0);
return IgniteSpring.start(cfg,applicationContext);
}
示例3: postProcessBeanFactory
import org.apache.ignite.configuration.IgniteConfiguration; //导入依赖的package包/类
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public void postProcessBeanFactory(
ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
String[] igniteConfigNames = configurableListableBeanFactory.getBeanNamesForType(IgniteConfiguration.class);
if (igniteConfigNames.length != 1) {
throw new IllegalArgumentException("Spring config must contain exactly one ignite configuration!");
}
String[] activeStoreConfigNames = configurableListableBeanFactory.getBeanNamesForType(BaseActiveStoreConfiguration.class);
if (activeStoreConfigNames.length != 1) {
throw new IllegalArgumentException("Spring config must contain exactly one active store configuration!");
}
BeanDefinition igniteConfigDef = configurableListableBeanFactory.getBeanDefinition(igniteConfigNames[0]);
MutablePropertyValues propertyValues = igniteConfigDef.getPropertyValues();
if (!propertyValues.contains(USER_ATTRS_PROP_NAME)) {
propertyValues.add(USER_ATTRS_PROP_NAME, new ManagedMap());
}
PropertyValue propertyValue = propertyValues.getPropertyValue(USER_ATTRS_PROP_NAME);
Map userAttrs = (Map)propertyValue.getValue();
TypedStringValue key = new TypedStringValue(CONFIG_USER_ATTR);
RuntimeBeanReference value = new RuntimeBeanReference(beanName);
userAttrs.put(key, value);
}
示例4: testManualHBaseInsertion
import org.apache.ignite.configuration.IgniteConfiguration; //导入依赖的package包/类
@Test
public void testManualHBaseInsertion() throws ServiceException, IOException {
IgniteConfiguration cfg = prepareConfig(false);
IgniteConfiguration cfg2 = new IgniteConfiguration(cfg);
cfg.setGridName("first");
cfg2.setGridName("second");
String cacheName = "myCache";
try (Ignite ignite = Ignition.getOrStart(cfg); Ignite ignite2 = Ignition.getOrStart(cfg2)) {
IgniteCache<String, String> cache = ignite.getOrCreateCache(cacheName);
cache.remove("Hello");
assertNull(cache.get("Hello"));
try (Connection conn = getHBaseConnection()) {
TableName tableName = TableName.valueOf(TABLE_NAME);
Table table = conn.getTable(tableName);
Serializer<Object> serializer = ObjectSerializer.INSTANCE;
Put put = new Put(serializer.serialize("Hello"));
put.addColumn(cacheName.getBytes(), QUALIFIER, serializer.serialize("World"));
table.put(put);
}
assertEquals("World", cache.get("Hello"));
}
}
示例5: createGridName
import org.apache.ignite.configuration.IgniteConfiguration; //导入依赖的package包/类
private String createGridName(IgniteConfiguration conf) {
String name = null;
if ( StringUtils.isNotEmpty( config.getInstanceName() ) ) {
name = config.getInstanceName();
}
else {
IgniteConfiguration igniteConfiguration = createIgniteConfiguration();
if ( StringUtils.isNotEmpty( igniteConfiguration.getIgniteInstanceName() ) ) {
name = igniteConfiguration.getIgniteInstanceName();
}
else if ( config.getUrl() != null ) {
name = config.getUrl().getPath();
name = name.replaceAll( "[\\,\\\",:,\\*,\\/,\\\\]", "_" );
}
else {
name = UUID.randomUUID().toString();
}
}
return name;
}
示例6: startIgnite_send
import org.apache.ignite.configuration.IgniteConfiguration; //导入依赖的package包/类
public static Ignite startIgnite_send(Map<String, String> group_attrs)
{
IgniteConfiguration cfg = new IgniteConfiguration ();
cfg.setPeerClassLoadingEnabled (true);
// 设置群组
cfg.setUserAttributes(group_attrs);
//配置断点自动重连
TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi();
discoverySpi.setNetworkTimeout (5000);
discoverySpi.setClientReconnectDisabled(true);
cfg.setDiscoverySpi(discoverySpi);
return Ignition.start(cfg);
}
示例7: build
import org.apache.ignite.configuration.IgniteConfiguration; //导入依赖的package包/类
@Override
public IgniteConfiguration build() {
IgniteConfiguration config = new IgniteConfiguration();
config.setPeerClassLoadingEnabled(true);
config.setClientMode(false);
TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
TcpDiscoveryMulticastIpFinder ipFinder = new TcpDiscoveryMulticastIpFinder();
ArrayList<String> addrs = new ArrayList<>();
addrs.add("127.0.0.1:47500..47509");
ipFinder.setAddresses(addrs);
discoSpi.setIpFinder(ipFinder);
config.setDiscoverySpi(discoSpi);
CacheConfiguration accountCacheCfg = new CacheConfiguration()
.setName("BREED")
.setAtomicityMode(TRANSACTIONAL)
.setIndexedTypes(
String.class, Breed.class
);
config.setCacheConfiguration(accountCacheCfg);
return config;
}
示例8: initIgnition
import org.apache.ignite.configuration.IgniteConfiguration; //导入依赖的package包/类
private void initIgnition() {
List<IgniteConfiguration> igniteConfigurations = new ArrayList<>();
ClassPathXmlApplicationContext xmlContext =
new ClassPathXmlApplicationContext(props.getConfigPath());
igniteConfigurations.addAll(xmlContext.getBeansOfType(IgniteConfiguration.class).values());
for (IgniteConfiguration config : igniteConfigurations) {
List<IgniteHolder> configs = igniteMap.get(config.getGridName());
if (configs == null) {
configs = new ArrayList<>();
igniteMap.put(config.getGridName(), configs);
}
configs.add(new IgniteHolder(config));
}
}
示例9: getDefaultIgniteConfig
import org.apache.ignite.configuration.IgniteConfiguration; //导入依赖的package包/类
private IgniteConfiguration getDefaultIgniteConfig(IgniteResource gridResource) {
IgniteConfiguration igniteConfiguration = new IgniteConfiguration();
igniteConfiguration.setGridName(getGridName(gridResource));
igniteConfiguration.setClientMode(getClientMode(gridResource));
igniteConfiguration.setPeerClassLoadingEnabled(getPeerClassLoadingEnabled(gridResource));
TcpDiscoverySpi tcpDiscoverySpi = new TcpDiscoverySpi();
TcpDiscoveryMulticastIpFinder ipFinder = new TcpDiscoveryMulticastIpFinder();
ipFinder.setAddresses(Collections.singletonList(getIpDiscoveryRange(gridResource)));
tcpDiscoverySpi.setIpFinder(ipFinder);
tcpDiscoverySpi.setLocalAddress(getLocalAddress(gridResource));
igniteConfiguration.setDiscoverySpi(tcpDiscoverySpi);
TcpCommunicationSpi communicationSpi = new TcpCommunicationSpi();
communicationSpi.setLocalAddress(props.getLocalAddress());
igniteConfiguration.setCommunicationSpi(communicationSpi);
return igniteConfiguration;
}
示例10: getConfiguration
import org.apache.ignite.configuration.IgniteConfiguration; //导入依赖的package包/类
/**
* Enhances the default configuration with the {#TcpDiscoveryRedisIpFinder}.
*
* @param gridName Grid name.
* @return Ignite configuration.
* @throws Exception If failed.
*/
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration configuration = getDefaultConfiguration(gridName);
TcpDiscoveryRedisIpFinder redisIpFinder = new TcpDiscoveryRedisIpFinder();
redisIpFinder.setServiceName(REDIS_SERVICE_NAME);
// first node => configure with redisConnectionString; second and subsequent
// shall be configured through system property
if (gridName.equals(getTestGridName(0)))
redisIpFinder.setRedisConnectionString("localhost:16379");
TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
// Increase max missed heartbeats to avoid unexpected node fails.
discoSpi.setMaxMissedHeartbeats(30);
// Set heartbeat interval to 1 second to speed up tests.
discoSpi.setHeartbeatFrequency(1000);
// Set clean frequency to 500 milliseconds to speed up address unregistering
discoSpi.setIpFinderCleanFrequency(500);
discoSpi.setIpFinder(redisIpFinder);
configuration.setDiscoverySpi(discoSpi);
return configuration;
}
示例11: setUp
import org.apache.ignite.configuration.IgniteConfiguration; //导入依赖的package包/类
@Before
public void setUp() {
TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
ipFinder.setAddresses(Collections.singletonList(HOST));
TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
discoSpi.setIpFinder(ipFinder);
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setDiscoverySpi(discoSpi);
cfg.setGridName("test");
ignite = Ignition.start(cfg);
Properties props = new Properties();
props.setProperty(IgniteSqlInterpreter.IGNITE_JDBC_URL, "jdbc:ignite:cfg://[email protected]");
props.setProperty(IgniteInterpreter.IGNITE_CLIENT_MODE, "false");
props.setProperty(IgniteInterpreter.IGNITE_PEER_CLASS_LOADING_ENABLED, "false");
intp = new IgniteInterpreter(props);
intp.open();
}
示例12: connect
import org.apache.ignite.configuration.IgniteConfiguration; //导入依赖的package包/类
/**
* Connect.
*
* @param masterConfig the master config
* @return the ignite grid connection
* @throws Exception the exception
*/
public IgniteGridConnection connect( MasterConfig masterConfig) throws Exception {
try {
String igniteConfigPath = masterConfig.getIgniteConfigPath();
if( igniteConfigPath == null ) throw new Exception("Required MasterConfig value igniteConfigPath is not set, try setting to location of ignite-iote2e.xml");
if( !igniteConfigPath.endsWith("/") ) igniteConfigPath = igniteConfigPath + "/";
String igniteConfigPathNameExt = igniteConfigPath + masterConfig.getIgniteConfigFile();
logger.info("Initializing Ignite, config file=" + igniteConfigPathNameExt + ", config name=" + masterConfig.getIgniteConfigName());
IgniteConfiguration igniteConfiguration = Ignition.loadSpringBean(
igniteConfigPathNameExt, masterConfig.getIgniteConfigName());
Ignition.setClientMode(masterConfig.isIgniteClientMode());
ignite = Ignition.getOrStart(igniteConfiguration);
cache = ignite.getOrCreateCache(masterConfig.getIgniteCacheName());
logger.debug("***************** create cache: cacheName={}, cache={}", masterConfig.getIgniteCacheName(), cache);
return this;
} catch( Exception e ) {
logger.error(e.getMessage(), e);
throw e;
}
}
示例13: initIgniteSender
import org.apache.ignite.configuration.IgniteConfiguration; //导入依赖的package包/类
/**
* Inits the ignite sender.
*
* @throws Exception the exception
*/
private void initIgniteSender() throws Exception {
try {
String cacheName = "iote2e-evalmulticlient-cache";
String igniteConfigPath = "/home/pete/development/gitrepo/iote2e/iote2e-tests/iote2e-shared/config_ignite/";
if( igniteConfigPath == null ) throw new Exception("Required MasterConfig value igniteConfigPath is not set, try setting to location of ignite-iote2e.xml");
if( !igniteConfigPath.endsWith("/") ) igniteConfigPath = igniteConfigPath + "/";
String igniteConfigPathNameExt = igniteConfigPath + "ignite-iote2e-local-peer-false.xml";
String configName = "ignite.cfg";
logger.info("Initializing Ignite, config file=" + igniteConfigPathNameExt + ", config name=" + configName);
IgniteConfiguration igniteConfiguration = Ignition.loadSpringBean(
igniteConfigPathNameExt, configName);
Ignition.setClientMode(true);
ignite = Ignition.getOrStart(igniteConfiguration);
cache = ignite.getOrCreateCache(cacheName);
} catch(Exception e ) {
logger.error(e.getMessage(), e);
throw e;
}
}
示例14: startGrid
import org.apache.ignite.configuration.IgniteConfiguration; //导入依赖的package包/类
/**
* Starts new grid with given name.
*
* @param igniteInstanceName Ignite instance name.
* @param ctx Spring context.
* @return Started grid.
* @throws Exception If failed.
*/
protected Ignite startGrid(String igniteInstanceName, IgniteConfiguration cfg, GridSpringResourceContext ctx)
throws Exception {
if (!isRemoteJvm(igniteInstanceName)) {
startingIgniteInstanceName.set(igniteInstanceName);
try {
Ignite node = IgnitionEx.start(cfg, ctx);
IgniteConfiguration nodeCfg = node.configuration();
log.info("Node started with the following configuration [id=" + node.cluster().localNode().id()
+ ", marshaller=" + nodeCfg.getMarshaller()
+ ", binaryCfg=" + nodeCfg.getBinaryConfiguration()
+ ", lateAff=" + nodeCfg.isLateAffinityAssignment() + "]");
return node;
}
finally {
startingIgniteInstanceName.set(null);
}
}
else
return startRemoteGrid(igniteInstanceName, null, ctx);
}
示例15: getConfiguration
import org.apache.ignite.configuration.IgniteConfiguration; //导入依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
cfg.setPublicThreadPoolSize(THREAD_COUNT);
DataStorageConfiguration mem = new DataStorageConfiguration();
mem.setPageSize(PAGE_SIZE);
cfg.setDataStorageConfiguration(mem);
CacheConfiguration[] ccfgs = new CacheConfiguration[CACHE_COUNT];
for (int i = 0; i < CACHE_COUNT; ++i) {
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setName(CACHE_PREFIX + i);
ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
ccfg.setCacheMode(CacheMode.PARTITIONED);
ccfgs[i] = ccfg;
}
cfg.setCacheConfiguration(ccfgs);
return cfg;
}