import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionAware;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionAware;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesInputBuilder;
*/
public class StatRpcMsgManagerImpl implements StatRpcMsgManager {
- private final static Logger LOG = LoggerFactory.getLogger(StatRpcMsgManagerImpl.class);
+
+ private static final Logger LOG = LoggerFactory.getLogger(StatRpcMsgManagerImpl.class);
private final Cache<String, TransactionCacheContainer<? super TransactionAware>> txCache;
- private final int queueCapacity = 5000;
+ private static final int MAX_CACHE_SIZE = 10000;
+ private static final int QUEUE_CAPACITY = 5000;
+
+ private static final String MSG_TRANS_ID_NOT_NULL = "TransactionId can not be null!";
+ private static final String MSG_NODE_ID_NOT_NULL = "NodeId can not be null!";
+ private static final String MSG_NODE_REF_NOT_NULL = "NodeRef can not be null!";
+ /**
+ * Number of possible statistic which are waiting for notification
+ * - check it in StatPermCollectorImpl method collectStatCrossNetwork()
+ */
+ private static final long POSSIBLE_STAT_WAIT_FOR_NOTIFICATION = 7;
private final OpendaylightGroupStatisticsService groupStatsService;
private final OpendaylightMeterStatisticsService meterStatsService;
rpcRegistry.getRpcService(OpendaylightQueueStatisticsService.class),
"OpendaylightQueueStatisticsService can not be null!");
- statsRpcJobQueue = new LinkedBlockingQueue<>(queueCapacity);
- /* nr. 7 is here nr. of possible statistic which are waiting for notification
- * - check it in StatPermCollectorImpl method collectStatCrossNetwork */
- txCache = CacheBuilder.newBuilder().expireAfterWrite((maxNodeForCollector * 7), TimeUnit.SECONDS)
- .maximumSize(10000).build();
+ statsRpcJobQueue = new LinkedBlockingQueue<>(QUEUE_CAPACITY);
+ txCache = CacheBuilder.newBuilder().expireAfterWrite((maxNodeForCollector * POSSIBLE_STAT_WAIT_FOR_NOTIFICATION), TimeUnit.SECONDS)
+ .maximumSize(MAX_CACHE_SIZE).build();
}
@Override
final Future<RpcResult<T>> future, final D inputObj, final NodeRef nodeRef,
final SettableFuture<TransactionId> resultTransId) {
- Futures.addCallback(JdkFutureAdapters.listenInPoolThread(future),
- new FutureCallback<RpcResult<? extends TransactionAware>>() {
-
+ class FutureCallbackImpl implements FutureCallback<RpcResult<? extends TransactionAware>> {
@Override
public void onSuccess(final RpcResult<? extends TransactionAware> result) {
final TransactionId id = result.getResult().getTransactionId();
LOG.warn("Response Registration for Statistics RPC call fail!", t);
}
- });
+ }
+
+ Futures.addCallback(JdkFutureAdapters.listenInPoolThread(future),new FutureCallbackImpl());
}
private String buildCacheKey(final TransactionId id, final NodeId nodeId) {
@Override
public Future<Optional<TransactionCacheContainer<?>>> getTransactionCacheContainer(
final TransactionId id, final NodeId nodeId) {
- Preconditions.checkArgument(id != null, "TransactionId can not be null!");
- Preconditions.checkArgument(nodeId != null, "NodeId can not be null!");
+ Preconditions.checkArgument(id != null, MSG_TRANS_ID_NOT_NULL);
+ Preconditions.checkArgument(nodeId != null, MSG_NODE_ID_NOT_NULL);
final String key = buildCacheKey(id, nodeId);
final SettableFuture<Optional<TransactionCacheContainer<?>>> result = SettableFuture.create();
@Override
public Future<Boolean> isExpectedStatistics(final TransactionId id, final NodeId nodeId) {
- Preconditions.checkArgument(id != null, "TransactionId can not be null!");
- Preconditions.checkArgument(nodeId != null, "NodeId can not be null!");
+ Preconditions.checkArgument(id != null, MSG_TRANS_ID_NOT_NULL);
+ Preconditions.checkArgument(nodeId != null, MSG_NODE_ID_NOT_NULL);
final String key = buildCacheKey(id, nodeId);
final SettableFuture<Boolean> checkStatId = SettableFuture.create();
@Override
public void addNotification(final TransactionAware notification, final NodeId nodeId) {
Preconditions.checkArgument(notification != null, "TransactionAware can not be null!");
- Preconditions.checkArgument(nodeId != null, "NodeId can not be null!");
+ Preconditions.checkArgument(nodeId != null, MSG_NODE_ID_NOT_NULL);
final RpcJobsQueue addNotification = new RpcJobsQueue() {
@Override
public Future<TransactionId> getAllGroupsStat(final NodeRef nodeRef) {
- Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+ Preconditions.checkArgument(nodeRef != null, MSG_NODE_REF_NOT_NULL);
final SettableFuture<TransactionId> result = SettableFuture.create();
final RpcJobsQueue getAllGroupStat = new RpcJobsQueue() {
@Override
public Future<TransactionId> getAllMetersStat(final NodeRef nodeRef) {
- Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+ Preconditions.checkArgument(nodeRef != null, MSG_NODE_REF_NOT_NULL);
final SettableFuture<TransactionId> result = SettableFuture.create();
final RpcJobsQueue getAllMeterStat = new RpcJobsQueue() {
@Override
public Future<TransactionId> getAllFlowsStat(final NodeRef nodeRef) {
- Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+ Preconditions.checkArgument(nodeRef != null, MSG_NODE_REF_NOT_NULL);
final SettableFuture<TransactionId> result = SettableFuture.create();
final RpcJobsQueue getAllFlowStat = new RpcJobsQueue() {
@Override
public void getAggregateFlowStat(final NodeRef nodeRef, final TableId tableId) {
- Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+ Preconditions.checkArgument(nodeRef != null, MSG_NODE_REF_NOT_NULL);
Preconditions.checkArgument(tableId != null, "TableId can not be null!");
final RpcJobsQueue getAggregateFlowStat = new RpcJobsQueue() {
@Override
public Future<TransactionId> getAllPortsStat(final NodeRef nodeRef) {
- Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+ Preconditions.checkArgument(nodeRef != null, MSG_NODE_REF_NOT_NULL);
final SettableFuture<TransactionId> result = SettableFuture.create();
final RpcJobsQueue getAllPortsStat = new RpcJobsQueue() {
@Override
public Future<TransactionId> getAllTablesStat(final NodeRef nodeRef) {
- Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+ Preconditions.checkArgument(nodeRef != null, MSG_NODE_REF_NOT_NULL);
final SettableFuture<TransactionId> result = SettableFuture.create();
final RpcJobsQueue getAllTableStat = new RpcJobsQueue() {
@Override
public Future<TransactionId> getAllQueueStat(final NodeRef nodeRef) {
- Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+ Preconditions.checkArgument(nodeRef != null, MSG_NODE_REF_NOT_NULL);
final SettableFuture<TransactionId> result = SettableFuture.create();
final RpcJobsQueue getAllQueueStat = new RpcJobsQueue() {
@Override
public Future<TransactionId> getAllMeterConfigStat(final NodeRef nodeRef) {
- Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+ Preconditions.checkArgument(nodeRef != null, MSG_NODE_REF_NOT_NULL);
final SettableFuture<TransactionId> result = SettableFuture.create();
final RpcJobsQueue qetAllMeterConfStat = new RpcJobsQueue() {
@Override
public void getGroupFeaturesStat(final NodeRef nodeRef) {
- Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+ Preconditions.checkArgument(nodeRef != null, MSG_NODE_REF_NOT_NULL);
final RpcJobsQueue getGroupFeaturesStat = new RpcJobsQueue() {
@Override
@Override
public void getMeterFeaturesStat(final NodeRef nodeRef) {
- Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+ Preconditions.checkArgument(nodeRef != null, MSG_NODE_REF_NOT_NULL);
final RpcJobsQueue getMeterFeaturesStat = new RpcJobsQueue() {
@Override
@Override
public Future<TransactionId> getAllGroupsConfStats(final NodeRef nodeRef) {
- Preconditions.checkArgument(nodeRef != null, "NodeRef can not be null!");
+ Preconditions.checkArgument(nodeRef != null, MSG_NODE_REF_NOT_NULL);
final SettableFuture<TransactionId> result = SettableFuture.create();
final RpcJobsQueue getAllGropConfStat = new RpcJobsQueue() {
private final Optional<? extends DataObject> confInput;
public <D extends DataObject> TransactionCacheContainerImpl (final TransactionId id, final D input, final NodeId nodeId) {
- this.id = Preconditions.checkNotNull(id, "TransactionId can not be null!");
+ this.id = Preconditions.checkNotNull(id, MSG_TRANS_ID_NOT_NULL);
notifications = new CopyOnWriteArrayList<T>();
confInput = Optional.fromNullable(input);
nId = nodeId;