本文整理汇总了Java中com.gemstone.gemfire.cache.Cache.getDistributedSystem方法的典型用法代码示例。如果您正苦于以下问题:Java Cache.getDistributedSystem方法的具体用法?Java Cache.getDistributedSystem怎么用?Java Cache.getDistributedSystem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.gemstone.gemfire.cache.Cache
的用法示例。
在下文中一共展示了Cache.getDistributedSystem方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: send
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public static void send(Cache c, Region region, Operation op) {
InternalDistributedSystem system = (InternalDistributedSystem)c.getDistributedSystem();
Set recps = system.getDistributionManager().getAdminMemberSet();
// @todo darrel: find out if any of these guys have region listeners
if (recps.isEmpty()) {
return;
}
SystemMemberCacheMessage msg = new SystemMemberCacheMessage();
if (region == null) {
msg.regionPath = null;
} else {
msg.regionPath = region.getFullPath();
}
msg.setRecipients(recps);
msg.op = op;
system.getDistributionManager().putOutgoing(msg);
}
示例2: SystemManagementService
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
protected SystemManagementService(Cache cache) {
this.cache = cache;
this.system = (InternalDistributedSystem) cache.getDistributedSystem();
// This is a safe check to ensure Management service does not start for a
// system which is disconnected.
// Most likely scenario when this will happen is when a cache is closed and we are at this point.
if (!system.isConnected()) {
throw new DistributedSystemDisconnectedException(
LocalizedStrings.InternalDistributedSystem_THIS_CONNECTION_TO_A_DISTRIBUTED_SYSTEM_HAS_BEEN_DISCONNECTED
.toLocalizedString());
}
this.localFilterChain = new LocalFilterChain();
this.jmxAdapter = new MBeanJMXAdapter();
this.repo = new ManagementResourceRepo();
this.notificationHub = new NotificationHub(repo);
if (system.getConfig().getJmxManager() && system.getConfig().getJmxManagerPort() != 0) {
this.agent = new ManagementAgent(system.getConfig(), system.getLogWriterI18n());
} else {
this.agent = null;
}
ManagementFunction function = new ManagementFunction(notificationHub);
FunctionService.registerFunction(function);
this.proxyListeners = new CopyOnWriteArrayList<ProxyListener>();
}
示例3: execute
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
@Override
public void execute(FunctionContext context) {
Object[] args = (Object[]) context.getArguments();
long timeout = ((Number) args[0]).intValue();
try{
Cache cache = CacheFactory.getAnyInstance();
InternalDistributedSystem ds = (InternalDistributedSystem) cache
.getDistributedSystem();
if (timeout > 0) {
ShutdownAllRequest.send(ds.getDistributionManager(), timeout);
} else {
ShutdownAllRequest.send(ds.getDistributionManager(), -1);
}
context.getResultSender().lastResult("succeeded in shutting down");
}catch(Exception ex){
context.getResultSender().lastResult("ShutDownFunction could not locate cache " +ex.getMessage());
}
}
示例4: calcBindHostName
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
* @param bindName the ip address or host name that this acceptor should
* bind to. If null or "" then calculate it.
* @return the ip address or host name this acceptor will listen on.
* An "" if all local addresses will be listened to.
* @since 5.7
*/
private static String calcBindHostName(Cache cache, String bindName) {
if (bindName != null && !bindName.equals("")) {
return bindName;
}
InternalDistributedSystem system = (InternalDistributedSystem)cache
.getDistributedSystem();
DistributionConfig config = system.getConfig();
String hostName = null;
// Get the server-bind-address. If it is not null, use it.
// If it is null, get the bind-address. If it is not null, use it.
// Otherwise set default.
String serverBindAddress = config.getServerBindAddress();
if (serverBindAddress != null && serverBindAddress.length() > 0) {
hostName = serverBindAddress;
} else {
String bindAddress = config.getBindAddress();
if (bindAddress != null && bindAddress.length() > 0) {
hostName = bindAddress;
}
}
return hostName;
}
示例5: initQueue
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private SingleWriteSingleReadRegionQueue initQueue(boolean conflate) {
Cache cache = getCache();
GatewayQueueAttributes queueAttrs = new GatewayQueueAttributes();
queueAttrs.setBatchConflation(true);
DiskStoreFactory dsf = cache.createDiskStoreFactory();
File overflowDir = new File(getUniqueName() + InternalDistributedSystem.getAnyInstance().getId());
if (!overflowDir.exists()) {
overflowDir.mkdir();
}
assertTrue(overflowDir.isDirectory());
File[] dirs1 = new File[] {overflowDir.getAbsoluteFile()};
dsf.setDiskDirs(dirs1).create(getUniqueName());
queueAttrs.setDiskStoreName(getUniqueName());
// queueAttrs.setOverflowDirectory(getUniqueName() + InternalDistributedSystem.getAnyInstance().getId());
CacheListener listener = new CacheListenerAdapter() {
};
GatewayStats stats = new GatewayStats(cache.getDistributedSystem(), "g1", "h1", null);
SingleWriteSingleReadRegionQueue queue = new SingleWriteSingleReadRegionQueue(cache, "region", queueAttrs, listener, stats);
return queue;
}
示例6: GemFireMemberStatus
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public GemFireMemberStatus(Cache cache) {
this.cache = cache;
DistributedSystem ds = null;
if (cache != null) {
ds = cache.getDistributedSystem();
}
initialize(ds);
}
示例7: execute
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
@Override
public void execute(FunctionContext context) {
Object argsObject = context.getArguments();
boolean hideDefaults = ((Boolean)argsObject).booleanValue();
Cache cache = CacheFactory.getAnyInstance();
InternalDistributedSystem system = (InternalDistributedSystem) cache.getDistributedSystem();
DistributionConfig config = system.getConfig();
DistributionConfigImpl distConfigImpl = ((DistributionConfigImpl) config);
MemberConfigurationInfo memberConfigInfo = new MemberConfigurationInfo();
memberConfigInfo.setJvmInputArguments(getJvmInputArguments());
memberConfigInfo.setGfePropsRuntime(distConfigImpl.getConfigPropsFromSource(ConfigSource.runtime()));
memberConfigInfo.setGfePropsSetUsingApi(distConfigImpl.getConfigPropsFromSource(ConfigSource.api()));
if (!hideDefaults)
memberConfigInfo.setGfePropsSetWithDefaults(distConfigImpl.getConfigPropsFromSource(null));
memberConfigInfo.setGfePropsSetFromFile(distConfigImpl.getConfigPropsDefinedUsingFiles());
//CacheAttributes
Map<String, String> cacheAttributes = new HashMap<String, String>();
cacheAttributes.put("copy-on-read", Boolean.toString(cache.getCopyOnRead()));
cacheAttributes.put("is-server", Boolean.toString(cache.isServer()));
cacheAttributes.put("lock-timeout", Integer.toString(cache.getLockTimeout()));
cacheAttributes.put("lock-lease", Integer.toString(cache.getLockLease()));
cacheAttributes.put("message-sync-interval", Integer.toString(cache.getMessageSyncInterval()));
cacheAttributes.put("search-timeout", Integer.toString(cache.getSearchTimeout()));
if (cache.getPdxDiskStore() == null) {
cacheAttributes.put("pdx-disk-store", "");
}
else {
cacheAttributes.put("pdx-disk-store", cache.getPdxDiskStore());
}
cacheAttributes.put("pdx-ignore-unread-fields", Boolean.toString(cache.getPdxIgnoreUnreadFields()));
cacheAttributes.put("pdx-persistent", Boolean.toString(cache.getPdxPersistent()));
cacheAttributes.put("pdx-read-serialized", Boolean.toString(cache.getPdxReadSerialized()));
if (hideDefaults) {
removeDefaults(cacheAttributes, getCacheAttributesDefaultValues());
}
memberConfigInfo.setCacheAttributes(cacheAttributes);
List<Map<String, String>> cacheServerAttributesList = new ArrayList<Map<String, String>>();
List<CacheServer> cacheServers = cache.getCacheServers();
if (cacheServers != null)
for (CacheServer cacheServer : cacheServers) {
Map<String, String> cacheServerAttributes = new HashMap<String, String>();
cacheServerAttributes.put("bind-address", cacheServer.getBindAddress());
cacheServerAttributes.put("hostname-for-clients", cacheServer.getHostnameForClients());
cacheServerAttributes.put("max-connections", Integer.toString(cacheServer.getMaxConnections()));
cacheServerAttributes.put("maximum-message-count", Integer.toString(cacheServer.getMaximumMessageCount()));
cacheServerAttributes.put("maximum-time-between-pings", Integer.toString(cacheServer.getMaximumTimeBetweenPings()));
cacheServerAttributes.put("max-threads", Integer.toString(cacheServer.getMaxThreads()));
cacheServerAttributes.put("message-time-to-live", Integer.toString(cacheServer.getMessageTimeToLive()));
cacheServerAttributes.put("notify-by-subscription", Boolean.toString(cacheServer.getNotifyBySubscription()));
cacheServerAttributes.put("port", Integer.toString(cacheServer.getPort()));
cacheServerAttributes.put("socket-buffer-size", Integer.toString(cacheServer.getSocketBufferSize()));
cacheServerAttributes.put("load-poll-interval", Long.toString(cacheServer.getLoadPollInterval()));
cacheServerAttributes.put("tcp-no-delay", Boolean.toString(cacheServer.getTcpNoDelay()));
if (hideDefaults)
removeDefaults(cacheServerAttributes, getCacheServerAttributesDefaultValues());
cacheServerAttributesList.add(cacheServerAttributes);
}
memberConfigInfo.setCacheServerAttributes(cacheServerAttributesList);
context.getResultSender().lastResult(memberConfigInfo);
}
示例8: disconnect
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
protected void disconnect(Cache cache) {
DistributedSystem dsys = cache.getDistributedSystem();
cache.close();
dsys.disconnect();
}
示例9: AbstractGatewaySender
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
protected AbstractGatewaySender(Cache cache, GatewaySenderAttributes attrs) {
this.cache = cache;
this.logger = (LogWriterI18n)cache.getLogger();
this.id = attrs.getId();
final StaticSystemCallbacks sysCb = GemFireCacheImpl
.getInternalProductCallbacks();
if (sysCb != null) {
this.uuid = sysCb.getGatewayUUID(this, attrs);
}
else {
// TODO: GemFire does not give UUIDs yet (need those for #48335)
this.uuid = 0;
}
this.socketBufferSize = attrs.getSocketBufferSize();
this.socketReadTimeout = attrs.getSocketReadTimeout();
this.queueMemory = attrs.getMaximumQueueMemory();
this.batchSize = attrs.getBatchSize();
this.batchTimeInterval = attrs.getBatchTimeInterval();
this.isConflation = attrs.isBatchConflationEnabled();
this.isPersistence = attrs.isPersistenceEnabled();
this.alertThreshold = attrs.getAlertThreshold();
this.manualStart = attrs.isManualStart();
this.isParallel = attrs.isParallel();
this.isForInternalUse = attrs.isForInternalUse();
this.diskStoreName = attrs.getDiskStoreName();
this.remoteDSId = attrs.getRemoteDSId();
this.eventFilters = attrs.getGatewayEventFilters();
setOnlyGatewayEnqueueEventFiltersFlag();
this.transFilters = attrs.getGatewayTransportFilters();
this.listeners = attrs.getAsyncEventListeners();
this.locatorDiscoveryCallback = attrs.getGatewayLocatoDiscoveryCallback();
this.isDiskSynchronous = attrs.isDiskSynchronous();
this.policy = attrs.getOrderPolicy();
this.dispatcherThreads = attrs.getDispatcherThreads();
this.parallelismForReplicatedRegion = attrs.getParallelismForReplicatedRegion();
//divide the maximumQueueMemory of sender equally using number of dispatcher threads.
//if dispatcherThreads is 1 then maxMemoryPerDispatcherQueue will be same as maximumQueueMemory of sender
this.maxMemoryPerDispatcherQueue = this.queueMemory / this.dispatcherThreads;
this.myDSId = InternalDistributedSystem.getAnyInstance().getDistributionManager().getDistributedSystemId();
this.serialNumber = DistributionAdvisor.createSerialNumber();
if (!(this.cache instanceof CacheCreation)) {
this.stopper = new Stopper(cache.getCancelCriterion());
this.senderAdvisor = GatewaySenderAdvisor.createGatewaySenderAdvisor(this, logger);
if (!this.isForInternalUse()) {
this.statistics = new GatewaySenderStats(cache.getDistributedSystem(),
id);
}
else {// this sender lies underneath the AsyncEventQueue. Need to have
// AsyncEventQueueStats
this.statistics = new AsyncEventQueueStats(
cache.getDistributedSystem(), AsyncEventQueueImpl
.getAsyncEventQueueIdFromSenderId(id));
}
}
this.isBucketSorted = attrs.isBucketSorted();
this.isHDFSQueue = attrs.isHDFSQueue();
}
示例10: getPartitionAttributeInfo
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private static PartitionAttributeInfo getPartitionAttributeInfo(String regionPath) throws AdminException
{
Cache cache = CacheFactory.getAnyInstance();
DistributedSystem ds = cache.getDistributedSystem();
DistributedSystemConfig config = AdminDistributedSystemFactory.defineDistributedSystem(ds, null);
AdminDistributedSystem adminSystem = AdminDistributedSystemFactory.getDistributedSystem(config);
try {
adminSystem.connect();
} catch (Exception ex) {
// already connected
}
SystemMember[] members = adminSystem.getSystemMemberApplications();
boolean isPR = true;
int redundantCopies = 0;
int totalNumBuckets = 0;
PartitionAttributeInfo pai = new PartitionAttributeInfo();
for (int i = 0; i < members.length; i++) {
SystemMemberCache scache = members[i].getCache();
if (scache != null) {
SystemMemberRegion region = scache.getRegion(regionPath);
PartitionAttributes pa = region.getPartitionAttributes();
if (pa == null) {
isPR = false;
break;
}
PartitionAttributeInfo.Partition part = new PartitionAttributeInfo.Partition();
part.localMaxMemory = region.getPartitionAttributes().getLocalMaxMemory();
part.toalMaxMemory = region.getPartitionAttributes().getTotalMaxMemory();
pai.addPartition(part);
redundantCopies = region.getPartitionAttributes().getRedundantCopies();
totalNumBuckets = region.getPartitionAttributes().getTotalNumBuckets();
}
}
if (isPR) {
pai.redundantCopies = redundantCopies;
pai.regionPath = regionPath;
pai.totalNumBuckets = totalNumBuckets;
} else {
pai = null;
}
return pai;
}
示例11: run
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public AggregateResults run(FunctionContext context)
{
AggregateResults results = new AggregateResults();
Cache cache = CacheFactory.getAnyInstance();
DistributedSystem ds = cache.getDistributedSystem();
DistributedMember member = ds.getDistributedMember();
Region region = cache.getRegion(regionPath);
if (region == null) {
results.setCode(AggregateResults.CODE_ERROR);
results.setCodeMessage("Undefined region: " + regionPath);
return results;
}
MapMessage message = new MapMessage();
message.put("MemberId", member.getId());
message.put("MemberName", ds.getName());
message.put("Host", member.getHost());
// message.put("IpAddress",
// dataSet.getNode().getMemberId().getIpAddress().getHostAddress());
// message.put("Port", parent.getNode().getMemberId().getPort());
message.put("Pid", member.getProcessId());
message.put("RegionPath", regionPath);
boolean isPR = region instanceof PartitionedRegion;
message.put("IsPR", isPR);
if (isPR) {
PartitionedRegion pr = (PartitionedRegion) region;
SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy h:mm:ss.SSS a");
message.put("LastAccessedTime", format.format(new Date(pr.getLastAccessedTime())));
message.put("LastModifiedTime", format.format(new Date(pr.getLastModifiedTime())));
// total local primary bucket size
int totalRegionSize = 0;
// if (priorTo6011) { // 5.7 - 6.0.1
// The following call is not returning the primary bucket regions.
// totalRegionSize = PartitionRegionHelper.getLocalData(pr).size();
// getDataStore() is null if peer client
if (pr.getDataStore() == null) {
message.put("IsPeerClient", true);
} else {
List<Integer> bucketIdList = pr.getDataStore().getLocalPrimaryBucketsListTestOnly();
for (Integer bucketId : bucketIdList) {
BucketRegion bucketRegion;
try {
bucketRegion = pr.getDataStore().getInitializedBucketForId(null, bucketId);
totalRegionSize += bucketRegion.size();
} catch (ForceReattemptException e) {
// ignore
}
}
message.put("IsPeerClient", false);
}
// } else {
// // The following call is not returning the primary bucket
// regions.
// // totalRegionSize =
// PartitionRegionHelper.getLocalData(pr).size();
//
// Region localRegion = new LocalDataSet(pr,
// pr.getDataStore().getAllLocalPrimaryBucketIds());
// totalRegionSize = localRegion.size();
// }
message.put("RegionSize", totalRegionSize);
} else {
message.put("IsPeerClient", false);
message.put("RegionSize", region.size());
message.put("Scope", region.getAttributes().getScope().toString());
}
message.put("DataPolicy", region.getAttributes().getDataPolicy().toString());
// info.evictionPolicy =
// region.getAttributes().getEvictionAttributes().getAlgorithm();
results.setDataObject(message);
return results;
}
示例12: testReconnectWithQuorum
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public void testReconnectWithQuorum() throws Exception {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
VM vm2 = host.getVM(2);
final int locPort = locatorPort;
final int secondLocPort = AvailablePortHelper.getRandomAvailableTCPPort();
final String xmlFileLoc = (new File(".")).getAbsolutePath();
// disable disconnects in the locator so we have some stability
host.getVM(locatorVMNumber).invoke(new SerializableRunnable("disable force-disconnect") {
public void run() {
GMS gms = (GMS)MembershipManagerHelper.getJChannel(InternalDistributedSystem.getConnectedInstance())
.getProtocolStack().findProtocol("GMS");
gms.disableDisconnectOnQuorumLossForTesting();
}}
);
SerializableCallable create = new SerializableCallable(
"Create Cache and Regions from cache.xml") {
public Object call() throws CacheException
{
// DebuggerSupport.waitForJavaDebugger(getLogWriter(), " about to create region");
locatorPort = locPort;
Properties props = getDistributedSystemProperties();
props.put("cache-xml-file", xmlFileLoc+"/MyDisconnect-cache.xml");
props.put("max-wait-time-reconnect", "1000");
props.put("max-num-reconnect-tries", "2");
props.put("log-file", "autoReconnectVM"+VM.getCurrentVMNum()+"_"+getPID()+".log");
Cache cache = new CacheFactory(props).create();
addExpectedException("com.gemstone.gemfire.ForcedDisconnectException||Possible loss of quorum");
Region myRegion = cache.getRegion("root/myRegion");
ReconnectDUnitTest.savedSystem = cache.getDistributedSystem();
myRegion.put("MyKey1", "MyValue1");
// MembershipManagerHelper.getMembershipManager(cache.getDistributedSystem()).setDebugJGroups(true);
// myRegion.put("Mykey2", "MyValue2");
return savedSystem.getDistributedMember();
}
};
vm0.invoke(create);
vm1.invoke(create);
vm2.invoke(create);
// view is [locator(3), vm0(15), vm1(10), vm2(10)]
/* now we want to cause vm0 and vm1 to force-disconnect. This may cause the other
* non-locator member to also disconnect, depending on the timing
*/
System.out.println("disconnecting vm0");
forceDisconnect(vm0);
pause(10000);
System.out.println("disconnecting vm1");
forceDisconnect(vm1);
/* now we wait for them to auto-reconnect*/
waitForReconnect(vm0);
waitForReconnect(vm1);
}
示例13: testDescribeConfig
import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public void testDescribeConfig() throws ClassNotFoundException, IOException {
createDefaultSetup(null);
final VM vm1 = Host.getHost(0).getVM(1);
final String vm1Name = "Member1";
final String controllerName = "Member2";
/***
* Create properties for the controller VM
*/
final Properties localProps = new Properties();
localProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
localProps.setProperty(DistributionConfig.LOG_LEVEL_NAME, "info");
localProps.setProperty(DistributionConfig.STATISTIC_SAMPLING_ENABLED_NAME, "true");
localProps.setProperty(DistributionConfig.ENABLE_TIME_STATISTICS_NAME, "true");
localProps.setProperty(DistributionConfig.NAME_NAME, controllerName);
localProps.setProperty(DistributionConfig.GROUPS_NAME, "G1");
getSystem(localProps);
Cache cache = getCache();
int ports[] = AvailablePortHelper.getRandomAvailableTCPPorts(1);
CacheServer cs = getCache().addCacheServer();
cs.setPort(ports[0]);
cs.setMaxThreads(10);
cs.setMaxConnections(9);
cs.start();
RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean();
List<String> jvmArgs = runtimeBean.getInputArguments();
getLogWriter().info("#SB Actual JVM Args : ");
for (String jvmArg : jvmArgs) {
getLogWriter().info("#SB JVM " + jvmArg);
}
InternalDistributedSystem system = (InternalDistributedSystem) cache.getDistributedSystem();
DistributionConfig config = system.getConfig();
config.setArchiveFileSizeLimit(1000);
String command = CliStrings.DESCRIBE_CONFIG + " --member=" + controllerName;
CommandProcessor cmdProcessor = new CommandProcessor();
cmdProcessor.createCommandStatement(command, Collections.EMPTY_MAP).process();
CommandResult cmdResult = executeCommand(command);
String resultStr = commandResultToString(cmdResult);
getLogWriter().info("#SB Hiding the defaults\n" + resultStr);
assertEquals(true, cmdResult.getStatus().equals(Status.OK));
assertEquals(true, resultStr.contains("G1"));
assertEquals(true, resultStr.contains(controllerName));
assertEquals(true, resultStr.contains("archive-file-size-limit"));
assertEquals(true, !resultStr.contains("copy-on-read"));
cmdResult = executeCommand(command + " --" + CliStrings.DESCRIBE_CONFIG__HIDE__DEFAULTS + "=false");
resultStr = commandResultToString(cmdResult);
getLogWriter().info("#SB No hiding of defaults\n" + resultStr);
assertEquals(true, cmdResult.getStatus().equals(Status.OK));
assertEquals(true, resultStr.contains("is-server"));
assertEquals(true, resultStr.contains(controllerName));
assertEquals(true, resultStr.contains("copy-on-read"));
cs.stop();
}