List of usage examples for org.springframework.data.gemfire GemfireTemplate get
@Override
public <K, V> V get(K key)
From source file:demo.vmware.commands.CommandModifyStringAttribute.java
@Override public CommandResult run(ConfigurableApplicationContext mainContext, List<String> parameters) { String regionName = parameters.get(0); String pk = parameters.get(1); String attributeName = parameters.get(2); String attributeValue = parameters.get(3); GemfireTemplate template = CommandRegionUtils.findTemplateForRegionName(mainContext, regionName); Object modelObject = template.get(pk); if (modelObject == null) { LOG.error("no object found in region " + regionName + " for key " + pk); return new CommandResult(null, " no object found in region " + regionName + " for key " + pk); } else {/* w ww . j a v a 2 s . com*/ setValue(modelObject, attributeName, attributeValue); template.put(pk, modelObject); return new CommandResult(null, "Attribute " + attributeName + " on object with key " + pk + " in region " + regionName + " successfully set to " + attributeValue); } }
From source file:demo.vmware.commands.CommandGetOneObject.java
@Override public CommandResult run(ConfigurableApplicationContext mainContext, List<String> parameters) { List<String> messages = new ArrayList<String>(); String targetRegionName = parameters.get(0); String targetKey = parameters.get(1); Map<String, GemfireTemplate> allRegionTemplates = CommandRegionUtils.getAllGemfireTemplates(mainContext); for (String key : allRegionTemplates.keySet()) { GemfireTemplate oneTemplate = allRegionTemplates.get(key); if (oneTemplate.getRegion().getName().equals(targetRegionName)) { Date startTimer = new Date(); Object foundObject = oneTemplate.get(targetKey); Date endTimer = new Date(); long timeDiffInMsec = endTimer.getTime() - startTimer.getTime(); double timeDiff = timeDiffInMsec / 1000.0; messages.add("Region " + targetRegionName + ": get key=" + targetKey + " contains " + foundObject + " took " + timeDiff + " secs"); }// ww w .jav a2 s . c om } if (messages.size() == 0) { messages.add("No data found."); } return new CommandResult(null, messages); }