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


Java GridCache类代码示例

本文整理汇总了Java中org.gridgain.grid.cache.GridCache的典型用法代码示例。如果您正苦于以下问题:Java GridCache类的具体用法?Java GridCache怎么用?Java GridCache使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: tryCache

import org.gridgain.grid.cache.GridCache; //导入依赖的package包/类
private static GridCache tryCache(String name) {
    GridCache cache = null;

    if (state.equals(ConnState.CONNECTED)) {
        logger.fine("[State " + state.name() + "] Trying to get cache " + name + " from the grid cause im connected to it");

        try {
            cache = grid.cache(name);
        } catch (RuntimeException e) {
            logger.log(Level.SEVERE, "Runtime exception when calling cache: " + e.getMessage());
            notifyFail();
        }
    } else {
        logger.fine("[State " + state.name() + "] Tried to get cache " + name + " from the grid, but im not connected");
    }

    return cache;
}
 
开发者ID:redBorder,项目名称:rb-bi,代码行数:19,代码来源:GridGainManager.java

示例2: main

import org.gridgain.grid.cache.GridCache; //导入依赖的package包/类
public static void main(String[] args) throws FileNotFoundException, IOException, GridException, InterruptedException {
	try (AnnotationConfigApplicationContext appCtx = new AnnotationConfigApplicationContext(LumenConfig.class)) {
		Grid grid = appCtx.getBean(Grid.class);
		
		GridCache<String, YagoRule> ruleCache = YagoRule.cache(grid);
		GridCache<String, YagoLabel> labelCache = YagoLabel.cache(grid);
		GridCache<String, ListMultimap<String, String>> entityByLabelCache = YagoLabel.entityByLabelCache(grid);
		
		grid.compute().broadcast((GridRunnable) () -> {
			try {
				log.info("For yagoRule, I have {} primary out of {} entries + {} swap", 
						ruleCache.primarySize(), ruleCache.size(), ruleCache.swapKeys());
				log.info("For yagoLabel, I have {} primary out of {} entries + {} swap", 
						labelCache.primarySize(), labelCache.size(), labelCache.swapKeys());
				log.info("For entityByLabel, I have {} primary out of {} entries + {} swap", 
						entityByLabelCache.primarySize(), entityByLabelCache.size(), entityByLabelCache.swapKeys());
			} catch (Exception e) {
				log.error("swapKeys error", e);
			}
		});
	}
	
}
 
开发者ID:lumenrobot,项目名称:lumen-kb,代码行数:24,代码来源:CacheStatsCli.java

示例3: main

import org.gridgain.grid.cache.GridCache; //导入依赖的package包/类
public static void main(String[] args) throws GridException {
		try (Grid grid = GridGain.start(
				System.getProperty("user.home") + "/gridgain-platform-os-6.1.9-nix/examples/config/example-cache.xml")) {
			GridCache<Integer, String> cache = grid.cache("partitioned");
//			String oldVal = cache.put(1, "1");
//			boolean success = cache.putx(2, "2");
//			boolean success2 = cache.putxIfAbsent(3, "3");
//			log.info("Current 3 value = {}", cache.get(3));
//			cache.transform(3, (it) -> it + "-transformed");
			log.info("Transformed 3 value = {}", cache.get(3));
		}
	}
 
开发者ID:ceefour,项目名称:gggettingstarted,代码行数:13,代码来源:BasicOperations.java

示例4: main

import org.gridgain.grid.cache.GridCache; //导入依赖的package包/类
public static void main(String[] args) throws GridException {
		try (Grid grid = GridGain.start(
				System.getProperty("user.home") + "/gridgain-platform-os-6.1.9-nix/examples/config/example-cache.xml")) {
			GridCache<Integer, Oya> cache = grid.cache("partitioned");
//			String oldVal = cache.put(1, "1");
//			boolean success = cache.putx(2, "2");
			boolean success2 = cache.putxIfAbsent(3, new Oya("3"));
			log.info("Current 3 value = {}", cache.get(3));
			cache.transform(3, (it) -> new Oya(it.name + "-transformed"));
			log.info("Transformed 3 value = {}", cache.get(3));
		}
	}
 
开发者ID:ceefour,项目名称:gggettingstarted,代码行数:13,代码来源:BasicOperations2.java

示例5: main

import org.gridgain.grid.cache.GridCache; //导入依赖的package包/类
public static void main(String[] args) throws FileNotFoundException, IOException, GridException, InterruptedException {
		try (AnnotationConfigApplicationContext appCtx = new AnnotationConfigApplicationContext(LumenConfig.class)) {
			Grid grid = appCtx.getBean(Grid.class);
			
			GridCache<String, YagoRule> ruleCache = YagoRule.cache(grid);
			if (ruleCache.isEmpty()) {
				log.info("Loading rules...");
				ruleCache.loadCache(null, 0);
			}
			log.info("For yagoRule, I have {} primary out of {} entries + {} swap", 
					ruleCache.primarySize(), ruleCache.size(), ruleCache.swapKeys());
			
			GridCache<String, YagoLabel> labelCache = YagoLabel.cache(grid);
//			if (labelCache.isEmpty()) {
//				log.info("Loading labels...");
//				labelCache.loadCache(null, 0);
//			}
			log.info("For yagoLabel, I have {} primary out of {} entries + {} swap", 
					labelCache.primarySize(), labelCache.size(), labelCache.swapKeys());
			
			GridCache<String, ListMultimap<String, String>> entityByLabelCache = YagoLabel.entityByLabelCache(grid);
//			if (labelCache.isEmpty()) {
//				log.info("Loading labels...");
//				labelCache.loadCache(null, 0);
//			}
			log.info("For entityByLabel, I have {} primary out of {} entries + {} swap", 
					entityByLabelCache.primarySize(), entityByLabelCache.size(), entityByLabelCache.swapKeys());
			
			Thread.currentThread().join();
		}
	}
 
开发者ID:lumenrobot,项目名称:lumen-kb,代码行数:32,代码来源:Worker.java

示例6: main

import org.gridgain.grid.cache.GridCache; //导入依赖的package包/类
public static void main(String[] args) throws FileNotFoundException, IOException, GridException {
	String entityId = "Muhammad";
	
	try (AnnotationConfigApplicationContext appCtx = new AnnotationConfigApplicationContext(LumenConfig.class)) {
		Grid grid = appCtx.getBean(Grid.class);
		GridCache<String, YagoLabel> labelCache = YagoLabel.cache(grid);
		log.info("Label for {}: {}", entityId, labelCache.get(entityId));
	}
	
}
 
开发者ID:lumenrobot,项目名称:lumen-kb,代码行数:11,代码来源:YagoSimpleLabelLookupCli.java

示例7: main

import org.gridgain.grid.cache.GridCache; //导入依赖的package包/类
public static void main(String[] args) throws FileNotFoundException, IOException, GridException {
		String upLabel = "Muhammad";
		
		try (Grid grid = GridGain.start(YagoLabelLookupCli2.class.getResource("yago.gridgain.xml"))) {
			GridCache<String, String> labelCache = grid.cache("yagoLabel");
//			labelCache.queries().createScanQuery(null).execute((GridClosure<Entry<String, String>, String>) (it) ->
//				it.getValue().equalsIgnoreCase(upLabel) ? it.getKey() : null);
			log.info("Finding resource for label '{}'...", upLabel);
			Collection<Set<String>> founds = labelCache.queries().createScanQuery(null).execute(new GridReducer<Entry<String, String>, Set<String>>() {
				Set<String> ids = new HashSet<>();
				
				@Override
				public boolean collect(Entry<String, String> e) {
					if (e.getValue().equalsIgnoreCase(upLabel)) {
						ids.add( e.getKey() );
					}
					return true;
				}
				
				@Override
				public Set<String> reduce() {
					return ids;
				}
			}).get();
			
			log.info("Found for {}: {}", upLabel, founds);
		}
		
	}
 
开发者ID:lumenrobot,项目名称:lumen-kb,代码行数:30,代码来源:YagoLabelLookupCli2.java

示例8: main

import org.gridgain.grid.cache.GridCache; //导入依赖的package包/类
public static void main(String[] args) throws FileNotFoundException, IOException, GridException {
		String upLabel = "Muhammad";
		
		try (AnnotationConfigApplicationContext appCtx = new AnnotationConfigApplicationContext(LumenConfig.class)) {
			Grid grid = appCtx.getBean(Grid.class);
			GridCache<String, ListMultimap<String, String>> entityByLabelCache = YagoLabel.entityByLabelCache(grid);
//			labelCache.queries().createScanQuery(null).execute((GridClosure<Entry<String, String>, String>) (it) ->
//				it.getValue().equalsIgnoreCase(upLabel) ? it.getKey() : null);
			log.info("Finding resource for label '{}'...", upLabel);
//			entityByLabelCache.removex(upLabel);
			ListMultimap<String, String> entities = entityByLabelCache.get(upLabel);
			log.info("Found for {}: {}", upLabel, entities);
		}
		
	}
 
开发者ID:lumenrobot,项目名称:lumen-kb,代码行数:16,代码来源:YagoLabelLookupCli3.java

示例9: main

import org.gridgain.grid.cache.GridCache; //导入依赖的package包/类
public static void main(String[] args) throws FileNotFoundException, IOException, GridException {
		String upLabel = "Muhammad";
		
		try (Grid grid = GridGain.start(YagoLabelLookupCli.class.getResource("yago.gridgain.xml"))) {
			GridCache<String, String> labelCache = grid.cache("yagoLabel");
//			labelCache.queries().createScanQuery(null).execute((GridClosure<Entry<String, String>, String>) (it) ->
//				it.getValue().equalsIgnoreCase(upLabel) ? it.getKey() : null);
			log.info("Finding resource for label '{}'...", upLabel);
			Collection<String> founds = labelCache.queries().createScanQuery(null).execute(new GridReducer<Entry<String, String>, String>() {
				String id;
				
				@Override
				public boolean collect(Entry<String, String> e) {
					if (e.getValue().equalsIgnoreCase(upLabel)) {
						id = e.getKey();
						return false;
					} else {
						return true;
					}
				}
				
				@Override
				public String reduce() {
					return id;
				}
			}).get();
			
			log.info("Found for {}: {}", upLabel, founds);
		}
		
	}
 
开发者ID:lumenrobot,项目名称:lumen-kb,代码行数:32,代码来源:YagoLabelLookupCli.java

示例10: ConnectedGridGainStateCache

import org.gridgain.grid.cache.GridCache; //导入依赖的package包/类
public ConnectedGridGainStateCache(GridCache<K, V> gridMap) {
    setMap(gridMap);
}
 
开发者ID:redBorder,项目名称:rb-bi,代码行数:4,代码来源:ConnectedGridGainStateCache.java

示例11: setMap

import org.gridgain.grid.cache.GridCache; //导入依赖的package包/类
public void setMap(GridCache<K, V> gridMap) {
    _gridMap = gridMap;
}
 
开发者ID:redBorder,项目名称:rb-bi,代码行数:4,代码来源:ConnectedGridGainStateCache.java

示例12: gridGainStateTest

import org.gridgain.grid.cache.GridCache; //导入依赖的package包/类
@Test
public void gridGainStateTest() throws GridException {
    List<String> topics = new ArrayList<String>();
    topics.add("location");

    GridConfiguration ggConf = new GridConfiguration();
    GridCacheConfiguration cacheLocation = new GridCacheConfiguration();
    cacheLocation.setName("location");
    cacheLocation.setCacheMode(GridCacheMode.PARTITIONED);
    ggConf.setCacheConfiguration(cacheLocation);
    Grid grid = GridGain.start(ggConf);

    GridCache<String, Map<String, Object>> map = grid.cache("location");

    GridGainStormState state = new GridGainStormState("location");

    List<List<Object>> keysList = new ArrayList<>();

    List<Object> keys = new ArrayList<>();
    keys.add("A");
    keysList.add(keys);

    keys = new ArrayList<>();
    keys.add("B");
    keysList.add(keys);

    keys = new ArrayList<>();
    keys.add("C");
    keysList.add(keys);

    List<Map<String, Map<String, Object>>> valuesList = new ArrayList<>();
    Map<String, Map<String, Object>> values = new HashMap<>();

    Map<String, Object> value = new HashMap<>();

    value.put("A1", 1);
    values.put("A", value);

    value = new HashMap<>();
    value.put("B1", 2);
    values.put("B", value);

    value = new HashMap<>();
    value.put("C1", 3);
    values.put("C", value);

    valuesList.add(values);


    state.multiPut(keysList, valuesList);


    List<Map<String, Map<String, Object>>> restoreList = state.multiGet(keysList);
    Map<String, Map<String, Object>> restore = restoreList.get(0);

    Assert.assertEquals(values.get("A"), restore.get("A"));
    Assert.assertEquals(values.get("A").get("A1"), restore.get("A").get("A1"));
    Assert.assertEquals(values.get("B"), restore.get("B"));
    Assert.assertEquals(values.get("B").get("B1"), restore.get("B").get("B1"));
    Assert.assertEquals(values.get("C"), restore.get("C"));
    Assert.assertEquals(values.get("C").get("C1"), restore.get("C").get("C1"));
    Assert.assertNotEquals(values.get("C").get("C1"), restore.get("B").get("B1"));

    grid.close();
}
 
开发者ID:redBorder,项目名称:rb-bi,代码行数:66,代码来源:GridGainStateTest.java

示例13: cache

import org.gridgain.grid.cache.GridCache; //导入依赖的package包/类
public static GridCache<String, YagoLabel> cache(Grid grid) {
	return grid.cache("yagoLabel");
}
 
开发者ID:lumenrobot,项目名称:lumen-kb,代码行数:4,代码来源:YagoLabel.java

示例14: entityByLabelCache

import org.gridgain.grid.cache.GridCache; //导入依赖的package包/类
public static GridCache<String, ListMultimap<String, String>> entityByLabelCache(
		Grid grid) {
	return grid.cache("yagoEntityByLabel");
}
 
开发者ID:lumenrobot,项目名称:lumen-kb,代码行数:5,代码来源:YagoLabel.java

示例15: cache

import org.gridgain.grid.cache.GridCache; //导入依赖的package包/类
public static GridCache<String, YagoRule> cache(Grid grid) {
	return grid.cache("yagoRule");
}
 
开发者ID:lumenrobot,项目名称:lumen-kb,代码行数:4,代码来源:YagoRule.java


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