public GroupStatistics build() { return new GroupStatisticsImpl(this); }
public GroupStatisticsBuilder(GroupStatistics base) { this._buckets = base.getBuckets(); this._byteCount = base.getByteCount(); this._duration = base.getDuration(); this._groupId = base.getGroupId(); this._packetCount = base.getPacketCount(); this._refCount = base.getRefCount(); if (base instanceof GroupStatisticsImpl) { GroupStatisticsImpl _impl = (GroupStatisticsImpl) base; this.augmentation = new HashMap<>(_impl.augmentation); } }
private GroupStatisticsImpl(GroupStatisticsBuilder base) { this._buckets = base.getBuckets(); this._byteCount = base.getByteCount(); this._duration = base.getDuration(); this._groupId = base.getGroupId(); this._packetCount = base.getPacketCount(); this._refCount = base.getRefCount(); switch (base.augmentation.size()) { case 0: this.augmentation = Collections.emptyMap(); break; case 1: final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.statistics.GroupStatistics>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.statistics.GroupStatistics>> e = base.augmentation.entrySet().iterator().next(); this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.statistics.GroupStatistics>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.statistics.GroupStatistics>>singletonMap(e.getKey(), e.getValue()); break; default : this.augmentation = new HashMap<>(base.augmentation); } }
long timeStamp = getTimeStamp(); builder[0].setMetricValue(new Counter64(new BigInteger("" + gs.getRefCount().getValue()))); builder[0].setTimeStamp(timeStamp); builder[1].setMetricValue(new Counter64(new BigInteger("" + gs.getPacketCount().getValue()))); builder[1].setTimeStamp(timeStamp); builder[2].setMetricValue(new Counter64(new BigInteger("" + gs.getByteCount().getValue()))); builder[2].setTimeStamp(timeStamp); } else { List<RecordKeys> recKeys = createRecordKeys(id); getCollector().createTSDRMetricRecordBuilder(nodeID,id, recKeys, "RefCount", "" + gs.getRefCount().getValue(), DataCategory.FLOWGROUPSTATS); getCollector().createTSDRMetricRecordBuilder(nodeID,id, recKeys, "PacketCount", "" + gs.getPacketCount().getValue(), DataCategory.FLOWGROUPSTATS); getCollector().createTSDRMetricRecordBuilder(nodeID,id, recKeys, "ByteCount", "" + gs.getByteCount().getValue(), DataCategory.FLOWGROUPSTATS);
private void statGroupCommit(final List<GroupStats> groupStats, final InstanceIdentifier<Node> nodeIdent, final ReadWriteTransaction tx) { Preconditions.checkNotNull(groupStats); Preconditions.checkNotNull(nodeIdent); Preconditions.checkNotNull(tx); final InstanceIdentifier<FlowCapableNode> fNodeIdent = nodeIdent.augmentation(FlowCapableNode.class); for (final GroupStats gStat : groupStats) { final GroupStatistics stats = new GroupStatisticsBuilder(gStat).build(); final InstanceIdentifier<Group> groupIdent = fNodeIdent.child(Group.class, new GroupKey(gStat.getGroupId())); final InstanceIdentifier<NodeGroupStatistics> nGroupStatIdent =groupIdent .augmentation(NodeGroupStatistics.class); final InstanceIdentifier<GroupStatistics> gsIdent = nGroupStatIdent.child(GroupStatistics.class); /* Statistics Writing */ Optional<Group> group = Optional.absent(); try { group = tx.read(LogicalDatastoreType.OPERATIONAL, groupIdent).checkedGet(); } catch (final ReadFailedException e) { LOG.debug("Read Operational/DS for Group node fail! {}", groupIdent, e); } if (group.isPresent()) { tx.merge(LogicalDatastoreType.OPERATIONAL, nGroupStatIdent, new NodeGroupStatisticsBuilder().build(), true); tx.put(LogicalDatastoreType.OPERATIONAL, gsIdent, stats); } } }
public GroupStatisticsBuilder setByteCount(Counter64 value) { if (value != null) { BigInteger _constraint = value.getValue(); boolean isValidRange = false; for (Range<BigInteger> r : _byteCount_range()) { if (r.contains(_constraint)) { isValidRange = true; } } if (!isValidRange) { throw new IllegalArgumentException(String.format("Invalid range: %s, expected: %s.", value, _byteCount_range)); } } this._byteCount = value; return this; } public static List<Range<BigInteger>> _byteCount_range() {
public GroupStatisticsBuilder setPacketCount(Counter64 value) { if (value != null) { BigInteger _constraint = value.getValue(); boolean isValidRange = false; for (Range<BigInteger> r : _packetCount_range()) { if (r.contains(_constraint)) { isValidRange = true; } } if (!isValidRange) { throw new IllegalArgumentException(String.format("Invalid range: %s, expected: %s.", value, _packetCount_range)); } } this._packetCount = value; return this; } public static List<Range<BigInteger>> _packetCount_range() {
public GroupStatisticsBuilder setRefCount(Counter32 value) { if (value != null) { BigInteger _constraint = BigInteger.valueOf(value.getValue()); boolean isValidRange = false; for (Range<BigInteger> r : _refCount_range()) { if (r.contains(_constraint)) { isValidRange = true; } } if (!isValidRange) { throw new IllegalArgumentException(String.format("Invalid range: %s, expected: %s.", value, _refCount_range)); } } this._refCount = value; return this; } public static List<Range<BigInteger>> _refCount_range() {
public GroupStatisticsBuilder setGroupId(GroupId value) { if (value != null) { BigInteger _constraint = BigInteger.valueOf(value.getValue()); boolean isValidRange = false; for (Range<BigInteger> r : _groupId_range()) { if (r.contains(_constraint)) { isValidRange = true; } } if (!isValidRange) { throw new IllegalArgumentException(String.format("Invalid range: %s, expected: %s.", value, _groupId_range)); } } this._groupId = value; return this; } public static List<Range<BigInteger>> _groupId_range() {
if (other.getBuckets() != null) { return false; } else if(!_buckets.equals(other.getBuckets())) { return false; if (other.getByteCount() != null) { return false; } else if(!_byteCount.equals(other.getByteCount())) { return false; if (other.getDuration() != null) { return false; } else if(!_duration.equals(other.getDuration())) { return false; if (other.getGroupId() != null) { return false; } else if(!_groupId.equals(other.getGroupId())) { return false; if (other.getPacketCount() != null) { return false; } else if(!_packetCount.equals(other.getPacketCount())) { return false;
private void statGroupCommit(final List<GroupStats> groupStats, final InstanceIdentifier<Node> nodeIdent, final ReadWriteTransaction tx) { Preconditions.checkNotNull(groupStats); Preconditions.checkNotNull(nodeIdent); Preconditions.checkNotNull(tx); final InstanceIdentifier<FlowCapableNode> fNodeIdent = nodeIdent.augmentation(FlowCapableNode.class); for (final GroupStats gStat : groupStats) { final GroupStatistics stats = new GroupStatisticsBuilder(gStat).build(); final InstanceIdentifier<Group> groupIdent = fNodeIdent.child(Group.class, new GroupKey(gStat.getGroupId())); final InstanceIdentifier<NodeGroupStatistics> nGroupStatIdent =groupIdent .augmentation(NodeGroupStatistics.class); final InstanceIdentifier<GroupStatistics> gsIdent = nGroupStatIdent.child(GroupStatistics.class); /* Statistics Writing */ Optional<Group> group = Optional.absent(); try { group = tx.read(LogicalDatastoreType.OPERATIONAL, groupIdent).checkedGet(); } catch (final ReadFailedException e) { LOG.debug("Read Operational/DS for Group node fail! {}", groupIdent, e); } if (group.isPresent()) { tx.merge(LogicalDatastoreType.OPERATIONAL, nGroupStatIdent, new NodeGroupStatisticsBuilder().build(), true); tx.put(LogicalDatastoreType.OPERATIONAL, gsIdent, stats); } } }
@Override public JsonObject objectToJsonMapper(DataObject ofStat) { JsonObject nodeGroupStatisticsJsonObject = null; GroupStatistics groupStat = (GroupStatistics) ofStat; if (groupStat.getByteCount() != null && groupStat.getDuration() != null && groupStat.getPacketCount() != null && groupStat.getBuckets() != null && groupStat.getGroupId() != null && groupStat.getRefCount() != null) { nodeGroupStatisticsJsonObject = factory.createObjectBuilder() .add(properties.getProperty("STAT_TYPE"), properties.getProperty("GRP_STAT")) .add(properties.getProperty("TIMESTAMP"), System.currentTimeMillis()) .add(properties.getProperty("OFSTATS"), factory.createObjectBuilder() .add(properties.getProperty("BYTE_COUNT"), groupStat.getByteCount().getValue()) .add(properties.getProperty("DURATION_SEC"), groupStat.getDuration().getSecond().getValue()) .add(properties.getProperty("DURATION_NANOSEC"), groupStat.getDuration().getNanosecond().getValue()) .add(properties.getProperty("PACK_COUNT"), groupStat.getPacketCount().getValue()) .add(properties.getProperty("REF_COUNT"), groupStat.getRefCount().getValue()) .add(properties.getProperty("GRP_ID"), groupStat.getGroupId().getValue()) .add(properties.getProperty("BUCK"), createBandStatsJsonArrayObject(groupStat.getBuckets().getBucketCounter()))) .build(); } return nodeGroupStatisticsJsonObject; }