use of org.apache.geode.distributed.internal.DistributionStats in project geode by apache.
the class MemberMBeanBridge method init.
public MemberMBeanBridge init() {
CachePerfStats cachePerfStats = this.cache.getCachePerfStats();
addCacheStats(cachePerfStats);
addFunctionStats(system.getFunctionServiceStats());
if (system.getDistributionManager().getStats() instanceof DistributionStats) {
DistributionStats distributionStats = (DistributionStats) system.getDistributionManager().getStats();
addDistributionStats(distributionStats);
}
if (PureJavaMode.osStatsAreAvailable()) {
Statistics[] systemStats = null;
if (HostStatHelper.isSolaris()) {
systemStats = system.findStatisticsByType(SolarisSystemStats.getType());
} else if (HostStatHelper.isLinux()) {
systemStats = system.findStatisticsByType(LinuxSystemStats.getType());
} else if (HostStatHelper.isOSX()) {
// @TODO once OSX stats are implemented
systemStats = null;
} else if (HostStatHelper.isWindows()) {
systemStats = system.findStatisticsByType(WindowsSystemStats.getType());
}
if (systemStats != null) {
systemStat = systemStats[0];
}
}
MemoryAllocator allocator = this.cache.getOffHeapStore();
if ((null != allocator)) {
OffHeapMemoryStats offHeapStats = allocator.getStats();
if (null != offHeapStats) {
addOffHeapStats(offHeapStats);
}
}
addSystemStats();
addVMStats();
initializeStats();
return this;
}
use of org.apache.geode.distributed.internal.DistributionStats in project geode by apache.
the class JGroupsMessengerJUnitTest method initMocks.
/**
* Create stub and mock objects
*/
private void initMocks(boolean enableMcast, Properties addProp) throws Exception {
if (messenger != null) {
messenger.stop();
messenger = null;
}
Properties nonDefault = new Properties();
nonDefault.put(DISABLE_TCP, "true");
nonDefault.put(MCAST_PORT, enableMcast ? "" + AvailablePortHelper.getRandomAvailableUDPPort() : "0");
nonDefault.put(MCAST_TTL, "0");
nonDefault.put(LOG_FILE, "");
nonDefault.put(LOG_LEVEL, "fine");
nonDefault.put(LOCATORS, "localhost[10344]");
nonDefault.put(ACK_WAIT_THRESHOLD, "1");
nonDefault.putAll(addProp);
DistributionConfigImpl config = new DistributionConfigImpl(nonDefault);
RemoteTransportConfig tconfig = new RemoteTransportConfig(config, DistributionManager.NORMAL_DM_TYPE);
stopper = mock(Stopper.class);
when(stopper.isCancelInProgress()).thenReturn(false);
manager = mock(Manager.class);
when(manager.isMulticastAllowed()).thenReturn(enableMcast);
healthMonitor = mock(HealthMonitor.class);
joinLeave = mock(JoinLeave.class);
ServiceConfig serviceConfig = new ServiceConfig(tconfig, config);
services = mock(Services.class);
when(services.getConfig()).thenReturn(serviceConfig);
when(services.getCancelCriterion()).thenReturn(stopper);
when(services.getHealthMonitor()).thenReturn(healthMonitor);
when(services.getManager()).thenReturn(manager);
when(services.getJoinLeave()).thenReturn(joinLeave);
DM dm = mock(DM.class);
InternalDistributedSystem system = InternalDistributedSystem.newInstanceForTesting(dm, nonDefault);
when(services.getStatistics()).thenReturn(new DistributionStats(system, statsId));
messenger = new JGroupsMessenger();
messenger.init(services);
// if I do this earlier then test this return messenger as null
when(services.getMessenger()).thenReturn(messenger);
String jgroupsConfig = messenger.getJGroupsStackConfig();
int startIdx = jgroupsConfig.indexOf("<org");
int insertIdx = jgroupsConfig.indexOf('>', startIdx + 4) + 1;
jgroupsConfig = jgroupsConfig.substring(0, insertIdx) + "<" + InterceptUDP.class.getName() + "/>" + jgroupsConfig.substring(insertIdx);
messenger.setJGroupsStackConfigForTesting(jgroupsConfig);
// System.out.println("jgroups config: " + jgroupsConfig);
messenger.start();
messenger.started();
interceptor = (InterceptUDP) messenger.myChannel.getProtocolStack().getTransport().getUpProtocol();
}
use of org.apache.geode.distributed.internal.DistributionStats in project geode by apache.
the class MemberLevelStatsJUnitTest method init.
public void init() {
cachePerfStats = new CachePerfStats(system);
funcServiceStats = new FunctionServiceStats(system, "FunctionExecution");
long statId = OSProcess.getId();
distributionStats = new DistributionStats(system, statId);
DistributionStats.enableClockStats = true;
dlockStats = new DLockStats(system, statId);
bridge = new MemberMBeanBridge();
bridge.addCacheStats(cachePerfStats);
bridge.addFunctionStats(funcServiceStats);
bridge.addDistributionStats(distributionStats);
bridge.addLockServiceStats(dlockStats);
VMStatsContract vmstats = system.getStatSampler().getVMStats();
assertTrue(vmstats instanceof VMStats50);
bridge.addSystemStats();
bridge.addVMStats();
for (int i = 0; i < 4; i++) {
DiskStoreStats stats = new DiskStoreStats(system, name.getMethodName() + i);
diskStatsList.add(stats);
bridge.addDiskStoreStats(stats);
}
for (int i = 0; i < 4; i++) {
PartitionedRegionStats stats = new PartitionedRegionStats(system, name.getMethodName() + i);
parRegionStatsList.add(stats);
bridge.addPartionRegionStats(stats);
}
}
Aggregations