当前位置: 首页>>代码示例>>Java>>正文


Java IgniteCache.put方法代码示例

本文整理汇总了Java中org.apache.ignite.IgniteCache.put方法的典型用法代码示例。如果您正苦于以下问题:Java IgniteCache.put方法的具体用法?Java IgniteCache.put怎么用?Java IgniteCache.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ignite.IgniteCache的用法示例。


在下文中一共展示了IgniteCache.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
@PostConstruct
    public void start() {
        log.info("Application is started for Node:" + ignite.cluster().nodes());
        CollectionConfiguration cfg = new CollectionConfiguration();
        IgniteQueue<Object> queue = ignite.queue("main", 0, cfg);
        IgniteCache<UUID, Operation> operationCache = ignite.cache("operationCache");
        log.info("Application is started for KeySizes:" + operationCache.size(CachePeekMode.PRIMARY));
        ArrayList<Event> events = new ArrayList<>();
        events.add(new Event(UUID.randomUUID(), IEventType.EXECUTE, EventState.CREATED, new String[]{"firstpar1","firstpar2"}));
        operationCache.put(UUID.randomUUID(), new Operation("TEST_CREATE", events, TransactionState.RUNNING));
        log.info("Application is started for KeySizes:" + operationCache.size(CachePeekMode.PRIMARY));
/*        Executors.newSingleThreadScheduledExecutor().scheduleWithFixedDelay(new Runnable() {
            @Override
            public void run() {
                kafkaTemplate.send("operation-events",UUID.randomUUID(),
                        new Operation("blaaggre",Arrays.asList(new Event()),TransactionState.RUNNING));

            }
        }, 3,3, TimeUnit.SECONDS);*/

//        log.info(transactionCache.get(UUID.fromString("4447a089-e5f7-477c-9807-79210fafa296")).toString());
    }
 
开发者ID:kloiasoft,项目名称:eventapis,代码行数:23,代码来源:EventController.java

示例2: createAlertEntry

import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
@Override
public void createAlertEntry(AlertEntry alertEntry) {
    // get the alert config if any
    final Optional<AlertConfigEntry> configForServiceIdCodeIdCount =
            alertsConfigStore.getConfigForServiceIdCodeIdCount(alertEntry.getServiceId(), alertEntry.getErrorCode());
    // get the max count of alerts before sending mail
    final int maxCount = configForServiceIdCodeIdCount.isPresent() ?
            configForServiceIdCodeIdCount.get().getMaxCount() : 1;
    final String mailTemplate = configForServiceIdCodeIdCount.isPresent() ?
            configForServiceIdCodeIdCount.get().getMailTemplate() : "ticket";
    // define the expiry of the entry in the cache
    final IgniteCache<String, AlertEntry> alertsCache = getAlertsCache();
    // insert into the key value store
    alertsCache.put(alertEntry.getAlertId(), alertEntry);
    // send the mail notification if max is there
    final SqlFieldsQuery sql = new SqlFieldsQuery("select count(*) from AlertEntry where serviceId = '" + alertEntry.getServiceId() + "' and errorCode = '" + alertEntry.getErrorCode() + "'");
    final List<List<?>> count = alertsCache.query(sql).getAll();
    if (count != null && !count.isEmpty()) {
        final Long result = (Long) count.get(0).get(0);
        if (result >= maxCount) {
            logger.debug("max alerts count is reached for : {}, start sending mail alert {}", alertEntry.toString());
            sendMail(alertEntry, configForServiceIdCodeIdCount.isPresent() ? configForServiceIdCodeIdCount.get().getEmails() : Collections.emptyList(), mailTemplate);
        }
    }
}
 
开发者ID:Romeh,项目名称:spring-boot-ignite,代码行数:26,代码来源:IgniteAlertsStore.java

示例3: gapDetectionProcessFillsGaps

import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
@Test
public void gapDetectionProcessFillsGaps() throws Exception {
    int firstKey = 1;
    PrimitivesHolder firstValue = new PrimitivesHolder();
    IgniteCache<Integer, PrimitivesHolder> cache = ignite().cache(PrimitivesHolder.CACHE);
    cache.put(firstKey, firstValue);

    long missedTx = createGap();
    int lastKey = 2;
    PrimitivesHolder lastValue = new PrimitivesHolder(true, (byte) 1, (short) 1, 1, 1, 1, 1);
    cache.put(lastKey, lastValue);

    awaitReconciliationOnTransaction(missedTx);
    awaitTransactions();
    Map<Integer, PrimitivesHolder> expected = new LinkedHashMap<>();
    expected.put(firstKey, firstValue);
    expected.put(lastKey, lastValue);
    assertObjectsInDB(expected, false);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:20,代码来源:SubscriberIntegrationTest.java

示例4: loadCache

import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
@Override
public void loadCache(IgniteBiInClosure<Integer, SpatialPartition>
                             igniteBiInClosure, @Nullable Object... objects)
        throws CacheLoaderException {
    IgniteCache<Integer,SpatialPartition> cache =
            (IgniteCache<Integer,SpatialPartition>) objects[0];
    Integer key = (Integer) objects[1];
    ArrayList<Long> values = (ArrayList<Long>) objects[2];

    SpatialPartition curr_value = cache.get(key);
    if(curr_value == null)
        curr_value = new SpatialPartition(values);
    else
        curr_value.mergeData(values);
    cache.put(key, curr_value);
}
 
开发者ID:amrmagdy4,项目名称:kite,代码行数:17,代码来源:BulkLoadSpatialCacheStore.java

示例5: singleCommit

import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
protected void singleCommit(TransactionSupplier txSupplier, IgniteInClosure<Long> onSingleCommit, long txId) {
    TransactionDataIterator it = txSupplier.dataIterator(txId);

    try (Transaction tx = ignite.transactions().txStart()) {
        while (it.hasNextCache()) {
            IgniteCache<Object, Object> cache = ignite.cache(it.nextCache());

            while (it.hasNextEntry()) {
                it.advance();
                Object value = it.getValue();
                if (ActiveCacheStore.TOMBSTONE.equals(value)) {
                    cache.remove(it.getKey());
                } else {
                    cache.put(it.getKey(), value);
                }
            }
        }
        tx.commit();
    }
    onSingleCommit.apply(txId);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:22,代码来源:AbstractIgniteCommitter.java

示例6: sequentialTransactions

import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
@Test(dataProvider = CACHE_INFO_PROVIDER)
public void sequentialTransactions(String cacheName, boolean asBinary) throws Exception {
    IgniteCache<Integer, PrimitivesHolder> cache = ignite().cache(cacheName);
    PrimitivesHolder first = DataProviders.PH_1;
    PrimitivesHolder second = DataProviders.PH_2;

    cache.put(1, first);
    cache.put(1, second);
    awaitTransactions();

    assertObjectsInDB(Collections.singletonMap(1, second), asBinary);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:13,代码来源:SubscriberIntegrationTest.java

示例7: testWriteThroughAndReadThrough

import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
@Test(dataProvider = PRIMITIVES_CACHE_NAMES_PROVIDER)
public void testWriteThroughAndReadThrough(String cacheName) throws Exception {
    PrimitivesHolder expected = DataProviders.PH_1;
    IgniteCache<Integer, PrimitivesHolder> cache = ignite().cache(cacheName);

    cache.put(1, expected);
    awaitTransactions();

    cache.withSkipStore().clear(1);

    PrimitivesHolder actual = cache.get(1);
    Assert.assertEquals(actual, expected);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:14,代码来源:SubscriberIntegrationTest.java

示例8: commit

import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
@Override
public void commit(Iterator<String> names, Iterator<List> keys, Iterator<List<?>> values) {
    IgniteCache<Object, Object> cache = ignite.cache(TX_COMMIT_CACHE_NAME);

    while (names.hasNext()) {
        names.next();
        List<?> keysList = keys.next();
        List<?> valuesList = values.next();
        for (int j = 0; j < keysList.size(); j++) {
            cache.put(keysList.get(j), valuesList.get(j));
        }
    }
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:14,代码来源:InCacheCommitter.java

示例9: process

import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public void process(IgniteCache cache, Map<?, ?> entries) {
    for (Map.Entry<?, ?> entry : entries.entrySet()) {
        cache.put(entry.getKey(), entry.getValue());
    }
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:8,代码来源:WriteWorker.java

示例10: writeValuesToCache

import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
void writeValuesToCache(Ignite ignite, boolean withReplication, int startIdx, int endIdx, int modifier) {
    try (Transaction tx = ignite.transactions().txStart()) {
        IgniteCache<Integer, Integer> cache = ignite.cache(CACHE_NAME);
        if (!withReplication) {
            cache = cache.withSkipStore();
        }
        for (int i = startIdx; i < endIdx; i++) {
            cache.put(i, i + modifier);
        }
        tx.commit();
    }
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:13,代码来源:BasicSynchronousReplicationIntegrationTest.java

示例11: testDelete

import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
@Test
public void testDelete() {
  IgniteConfiguration cfg = prepareConfig();
  IgniteConfiguration cfg2 = new IgniteConfiguration(cfg);
  cfg.setGridName("first");
  cfg2.setGridName("second");
  try (Ignite ignite = Ignition.getOrStart(cfg); Ignite ignite2 = Ignition.getOrStart(cfg2)) {
    IgniteCache<String, String> cache = ignite.getOrCreateCache("myCache");
    cache.put("Hello", "World");
    cache.put("Hello", "World");
    assertEquals("World", cache.get("Hello"));
    cache.remove("Hello");
    assertNull(cache.get("Hello"));
  }
}
 
开发者ID:bakdata,项目名称:ignite-hbase,代码行数:16,代码来源:HBaseCacheStoreTest.java

示例12: testTableAndColumnFamilyCreation

import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
@Test
public void testTableAndColumnFamilyCreation() throws IOException, ServiceException {
  try (Connection conn = getHBaseConnection()) {
    Admin admin = conn.getAdmin();
    TableName tableName = TableName.valueOf(TABLE_NAME);
    deleteTable(admin, tableName);
    assertFalse(admin.tableExists(tableName));
    IgniteConfiguration cfg = prepareConfig();
    IgniteConfiguration cfg2 = new IgniteConfiguration(cfg);
    cfg.setGridName("first");
    cfg2.setGridName("second");
    try (Ignite ignite = Ignition.getOrStart(cfg); Ignite ignite2 = Ignition
        .getOrStart(cfg2)) {
      String cacheName = "myCache";
      String otherCacheName = "myOtherCache";
      IgniteCache<String, String> cache = ignite.getOrCreateCache(cacheName);
      IgniteCache<String, String> otherCache = ignite.getOrCreateCache(otherCacheName);
      assertFalse(admin.tableExists(tableName));
      cache.put("Hello", "World");
      assertTrue(admin.tableExists(tableName));
      assertTrue(admin.getTableDescriptor(tableName).hasFamily(cacheName.getBytes()));
      assertFalse(
          admin.getTableDescriptor(tableName).hasFamily(otherCacheName.getBytes()));
      otherCache.put("Hello", "World");
      assertTrue(admin.tableExists(tableName));
      assertTrue(
          admin.getTableDescriptor(tableName).hasFamily(otherCacheName.getBytes()));
    }
  }
}
 
开发者ID:bakdata,项目名称:ignite-hbase,代码行数:31,代码来源:HBaseCacheStoreTest.java

示例13: testTableNameNotNull

import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
@Test(expected = CacheException.class)
public void testTableNameNotNull() {
  HBaseCacheStoreSessionListener cssl = new HBaseCacheStoreSessionListener(null);
  applyHBaseConfiguration(cssl);
  IgniteConfiguration cfg = prepareConfig(cssl);
  IgniteConfiguration cfg2 = new IgniteConfiguration(cfg);
  cfg.setGridName("first");
  cfg2.setGridName("second");
  try (Ignite ignite = Ignition.getOrStart(cfg); Ignite ignite2 = Ignition.getOrStart(cfg2)) {
    IgniteCache<String, String> cache = ignite.getOrCreateCache("myCache");
    cache.put("Hello", "World");
  }
}
 
开发者ID:bakdata,项目名称:ignite-hbase,代码行数:14,代码来源:HBaseCacheStoreTest.java

示例14: insertOrUpdateTuple

import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
@Override
public void insertOrUpdateTuple(EntityKey key, TuplePointer tuplePointer, TupleContext tupleContext) throws TupleAlreadyExistsException {
	IgniteCache<Object, BinaryObject> entityCache = provider.getEntityCache( key.getMetadata() );
	Tuple tuple = tuplePointer.getTuple();

	Object keyObject = null;
	BinaryObjectBuilder builder = null;
	IgniteTupleSnapshot tupleSnapshot = (IgniteTupleSnapshot) tuple.getSnapshot();
	keyObject = tupleSnapshot.getCacheKey();
	if ( tuple.getSnapshotType() == SnapshotType.UPDATE ) {
		builder = provider.createBinaryObjectBuilder( tupleSnapshot.getCacheValue() );
	}
	else {
		builder = provider.createBinaryObjectBuilder( provider.getEntityTypeName( key.getMetadata().getTable() ) );
	}
	for ( String columnName : tuple.getColumnNames() ) {
		Object value = tuple.get( columnName );
		if ( value != null ) {
			builder.setField( StringHelper.realColumnName( columnName ), value );
		}
		else {
			builder.removeField( StringHelper.realColumnName( columnName ) );
		}
	}
	BinaryObject valueObject = builder.build();
	entityCache.put( keyObject, valueObject );
	tuplePointer.setTuple( new Tuple( new IgniteTupleSnapshot( keyObject, valueObject, key.getMetadata() ), SnapshotType.UPDATE ) );
}
 
开发者ID:hibernate,项目名称:hibernate-ogm-ignite,代码行数:29,代码来源:IgniteDialect.java

示例15: loadCache

import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
@Override
public void loadCache(IgniteBiInClosure<String, ArrayList<Long>>
    igniteBiInClosure, @Nullable Object... objects) throws CacheLoaderException {
    IgniteCache<String,ArrayList<Long>> cache =
            (IgniteCache<String,ArrayList<Long>>) objects[0];
    String key = (String) objects[1];
    ArrayList<Long> values = (ArrayList<Long>) objects[2];
    ArrayList<Long> curr_value = cache.get(key);
    if(curr_value == null)
        curr_value = new ArrayList<Long>();
    curr_value.addAll(values);
    cache.put(key, curr_value);
}
 
开发者ID:amrmagdy4,项目名称:kite,代码行数:14,代码来源:BulkLoadCacheStore.java


注:本文中的org.apache.ignite.IgniteCache.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。