com.gemstone.gemfire.management.bean.stats.GatewayReceiverStatsJUnit Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gemfire-junit Show documentation
Show all versions of gemfire-junit Show documentation
SnappyData store based off Pivotal GemFireXD
/*
* Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You
* may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License. See accompanying
* LICENSE file.
*/
package com.gemstone.gemfire.management.bean.stats;
import com.gemstone.gemfire.cache.server.ServerLoad;
import com.gemstone.gemfire.internal.cache.wan.GatewayReceiverStats;
import com.gemstone.gemfire.management.internal.beans.GatewayReceiverMBeanBridge;
/**
* @author rishim
*/
public class GatewayReceiverStatsJUnit extends MBeanStatsTestCase {
private GatewayReceiverMBeanBridge bridge;
private GatewayReceiverStats receiverStats;
public GatewayReceiverStatsJUnit(String name) {
super(name);
}
public void init() {
receiverStats = GatewayReceiverStats.createGatewayReceiverStats("Test Sock Name");
bridge = new GatewayReceiverMBeanBridge();
bridge.addGatewayReceiverStats(receiverStats);
}
public void testServerStats() throws InterruptedException{
long startTime = System.currentTimeMillis();
receiverStats.incCurrentClients();
receiverStats.incConnectionThreads();
receiverStats.incThreadQueueSize();
receiverStats.incCurrentClientConnections();
receiverStats.incFailedConnectionAttempts();
receiverStats.incConnectionsTimedOut();
receiverStats.incReadQueryRequestTime(startTime);
receiverStats.incSentBytes(20);
receiverStats.incReceivedBytes(20);
receiverStats.incReadGetRequestTime(startTime);
receiverStats.incProcessGetTime(startTime);
receiverStats.incReadPutRequestTime(startTime);
receiverStats.incProcessPutTime(startTime);
ServerLoad load = new ServerLoad(1,1,1,1);
receiverStats.setLoad(load);
sample();
assertEquals(1, getCurrentClients());
assertEquals(1, getConnectionThreads());
assertEquals(1, getThreadQueueSize());
assertEquals(1, getClientConnectionCount());
assertEquals(1, getTotalFailedConnectionAttempts());
assertEquals(1, getTotalConnectionsTimedOut());
assertEquals(20, getTotalSentBytes());
assertEquals(20, getTotalReceivedBytes());
assertEquals(1.0,getConnectionLoad());
assertEquals(1.0,getLoadPerConnection());
assertEquals(1.0,getLoadPerQueue());
assertEquals(1.0,getQueueLoad());
assertTrue(getGetRequestRate() >0);
assertTrue(getGetRequestAvgLatency() >0);
assertTrue(getPutRequestRate() >0);
assertTrue(getPutRequestAvgLatency() >0);
bridge.stopMonitor();
// TODO:FAIL: assertEquals(0, getCurrentClients());
// TODO:FAIL: assertEquals(0, getConnectionThreads());
}
public void testReceiverStats() throws InterruptedException{
receiverStats.incEventsReceived(100);
receiverStats.incUpdateRequest();
receiverStats.incCreateRequest();
receiverStats.incDestroyRequest();
receiverStats.incDuplicateBatchesReceived();
receiverStats.incOutoforderBatchesReceived();
sample();
assertTrue(getEventsReceivedRate() >0);
assertTrue(getCreateRequestsRate() >0);
assertTrue(getDestroyRequestsRate() >0);
assertTrue(getUpdateRequestsRate() >0);
assertEquals(1, getDuplicateBatchesReceived());
assertEquals(1, getOutoforderBatchesReceived());
bridge.stopMonitor();
// TODO:FAIL: assertEquals(0, getOutoforderBatchesReceived());
// TODO:FAIL: assertEquals(0, getDuplicateBatchesReceived());
}
private float getCreateRequestsRate() {
return bridge.getCreateRequestsRate();
}
private float getDestroyRequestsRate() {
return bridge.getDestroyRequestsRate();
}
private int getDuplicateBatchesReceived() {
return bridge.getDuplicateBatchesReceived();
}
private int getOutoforderBatchesReceived() {
return bridge.getOutoforderBatchesReceived();
}
private float getUpdateRequestsRate() {
return bridge.getUpdateRequestsRate();
}
private float getEventsReceivedRate() {
return bridge.getEventsReceivedRate();
}
private double getConnectionLoad() {
return bridge.getConnectionLoad();
}
private int getConnectionThreads() {
return bridge.getConnectionThreads();
}
private long getGetRequestAvgLatency() {
return bridge.getGetRequestAvgLatency();
}
private float getGetRequestRate() {
return bridge.getGetRequestRate();
}
private long getPutRequestAvgLatency() {
return bridge.getPutRequestAvgLatency();
}
private float getPutRequestRate() {
return bridge.getPutRequestRate();
}
private double getLoadPerConnection() {
return bridge.getLoadPerConnection();
}
private double getLoadPerQueue() {
return bridge.getLoadPerQueue();
}
private double getQueueLoad() {
return bridge.getQueueLoad();
}
private int getThreadQueueSize() {
return bridge.getThreadQueueSize();
}
private int getTotalConnectionsTimedOut() {
return bridge.getTotalConnectionsTimedOut();
}
private int getTotalFailedConnectionAttempts() {
return bridge.getTotalFailedConnectionAttempts();
}
private long getTotalSentBytes() {
return bridge.getTotalSentBytes();
}
private long getTotalReceivedBytes() {
return bridge.getTotalReceivedBytes();
}
private int getClientConnectionCount() {
return bridge.getClientConnectionCount();
}
private int getCurrentClients() {
return bridge.getCurrentClients();
}
}