public PCMMGateReq build() {
return new PCMMGateReq(amid, subscriberID, transactionID, gateSpec, trafficProfile, classifiers,
- gateID, error, gateState, gateTimeInfo, gateUsageInfo);
+ gateID, error, gateState, gateTimeInfo, gateUsageInfo);
}
public void setAmId(final AmId qosAmId) {
byte tosMask = (byte)0x0;
short srcPort = (short) 0;
short dstPort = (short) 0;
- byte priority = (byte) 64;
- //byte priority = index.byteValue();
-
+ //byte priority = (byte) 64;
+ byte priority = (byte) (64+index);
+
// Legacy classifier
-
+
// Protocol -- zero is match any
if (qosClassifier.getProtocol() != null) {
protocol = Protocol.valueOf(qosClassifier.getProtocol().getValue().shortValue());
} else {
protocol = Protocol.NONE;
}
-
- // IP Addresss and mask wildcards - addr byte 0 for no match (or match anything)
-
+
+ // IP Addresss and mask wildcards - addr byte 0 for no match (or match anything)
+
Inet4Address srcAddress = (Inet4Address) getByName("0.0.0.0");
-
+
if (qosClassifier.getSrcIp() != null) {
- srcAddress = (Inet4Address) getByName(qosClassifier.getSrcIp().getValue());
+ srcAddress = (Inet4Address) getByName(qosClassifier.getSrcIp().getValue());
}
-
+
Inet4Address dstAddress = (Inet4Address) getByName("0.0.0.0");
-
+
if (qosClassifier.getDstIp() != null) {
dstAddress = (Inet4Address) getByName(qosClassifier.getDstIp().getValue());
}
-
-
+
+
if (qosClassifier.getSrcPort() != null) {
srcPort = qosClassifier.getSrcPort().getValue().shortValue();
}
}
// push the classifier to the gate request
classifiers.add(new org.pcmm.gates.impl.Classifier(protocol, tosOverwrite, tosMask, srcAddress, dstAddress, srcPort,
- dstPort, priority));
+ dstPort, priority));
}
-
+
private void addExtClassifier(final Short index, final ExtClassifier qosExtClassifier) {
// Extended classifier
- final byte priority = (byte) 64;
+ final byte priority = (byte) (index+64);
final ActivationState activationState = ActivationState.ACTIVE;
// Protocol -- zero is match any
final Protocol protocol;
Inet4Address srcIpAddr = (Inet4Address) getByName("0.0.0.0");
if (qosExtClassifier.getSrcIp() != null) {
- srcIpAddr = getInet4Address(qosExtClassifier.getSrcIp());
+ srcIpAddr = getInet4Address(qosExtClassifier.getSrcIp());
}
-
+
Inet4Address dstIpAddr = (Inet4Address) getByName("0.0.0.0");
if (qosExtClassifier.getDstIp() != null) {
- dstIpAddr = getInet4Address(qosExtClassifier.getDstIp());
+ dstIpAddr = getInet4Address(qosExtClassifier.getDstIp());
}
-
+
//mask
Inet4Address srcIpMask = (Inet4Address) getByName("255.255.255.255");
if (qosExtClassifier.getSrcIpMask() != null) {
- srcIpMask = getInet4Address(qosExtClassifier.getSrcIpMask());
+ srcIpMask = getInet4Address(qosExtClassifier.getSrcIpMask());
}
-
+
Inet4Address dstIpMask = (Inet4Address) getByName("255.255.255.255");
if (qosExtClassifier.getDstIpMask() != null) {
- dstIpMask = getInet4Address(qosExtClassifier.getDstIpMask());
+ dstIpMask = getInet4Address(qosExtClassifier.getDstIpMask());
}
-
+
// TODO - find out what the classifier ID should really be. It was never getting set previously
final short classifierId = (short)index;
// TODO - try to make these two variables immutable
byte srcPrefixLen = (byte) 128;
Inet6Address srcAddress = (Inet6Address) getByName("0::0");
-
+
if (qosIpv6Classifier.getSrcIp6() != null) {
String[] parts = qosIpv6Classifier.getSrcIp6().getValue().split("/");
String Ipv6AddressStr = parts[0];
tcMask = qosIpv6Classifier.getTcHigh().getValue().byteValue();
else if (qosIpv6Classifier.getTcLow() != null) tcMask = (byte) 0xff;
else tcMask = (byte) 0x00;
-
+
FlowLabel flowLabelFlag = FlowLabel.IRRELEVANT;
int flowLabelId = 0;
-
+
if (qosIpv6Classifier.getFlowLabel() != null) {
- flowLabelFlag = FlowLabel.VALID;
- flowLabelId = qosIpv6Classifier.getFlowLabel().intValue();
+ flowLabelFlag = FlowLabel.VALID;
+ flowLabelId = qosIpv6Classifier.getFlowLabel().intValue();
}
-
+
// TODO - find out what the classifier ID should really be. It was never getting set previously
final short classifierId = (short)index;
// push the IPv6 classifier to the gate request
classifiers.add(
- new org.pcmm.gates.impl.IPv6Classifier(srcAddress, dstAddress, srcPortBegin, dstPortBegin, (byte) 64,
+ new org.pcmm.gates.impl.IPv6Classifier(srcAddress, dstAddress, srcPortBegin, dstPortBegin, (byte) (index+64),
srcPortEnd, dstPortEnd, classifierId, ActivationState.ACTIVE, action, flowLabelFlag, tcLow,
tcHigh, tcMask, flowLabelId, nextHdr, srcPrefixLen, dstPrefLen));
}
@Override
public void onSessionInitiated(ProviderContext session) {
logger.info("Packetcable Session Initiated");
- logger.info("logging levels: error={}, warn={}, info={}, debug={}, trace={}", logger.isErrorEnabled(),
- logger.isWarnEnabled(), logger.isInfoEnabled(), logger.isDebugEnabled(), logger.isTraceEnabled());
+ logger.info("logging levels: error={}, warn={}, info={}, debug={}, trace={}", logger.isErrorEnabled(), logger.isWarnEnabled(), logger.isInfoEnabled(), logger.isDebugEnabled(), logger.isTraceEnabled());
dataBroker = session.getSALService(DataBroker.class);
// ValidationException does not need to be thrown again
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
private <T extends DataObject> void saveErrors(@Nonnull Map<InstanceIdentifier<T>, ValidationException> errorMap,
- @Nonnull Map<InstanceIdentifier<T>, T> dataMap) {
+ @Nonnull Map<InstanceIdentifier<T>, T> dataMap) {
final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
@Override
protected void handleUpdatedData(final Map<InstanceIdentifier<Ccap>, Ccap> updatedCcaps,
- final Map<InstanceIdentifier<Ccap>, Ccap> originalCcaps) {
+ final Map<InstanceIdentifier<Ccap>, Ccap> originalCcaps) {
// TODO actually support updates
@Override
protected void handleRemovedData(final Set<InstanceIdentifier<Ccap>> removedCcapPaths,
- final Map<InstanceIdentifier<Ccap>, Ccap> originalCcaps) {
+ final Map<InstanceIdentifier<Ccap>, Ccap> originalCcaps) {
for (InstanceIdentifier<Ccap> iid : removedCcapPaths) {
final Ccap nukedCcap = originalCcaps.get(iid);
}
private void saveGateError(@Nonnull final InstanceIdentifier<Gate> gateIID, @Nonnull final String gatePathStr,
- @Nonnull final String error) {
+ @Nonnull final String error) {
checkNotNull(gateIID);
checkNotNull(error);
@Override
protected void handleUpdatedData(final Map<InstanceIdentifier<Gate>, Gate> updatedData,
- final Map<InstanceIdentifier<Gate>, Gate> originalData) {
+ final Map<InstanceIdentifier<Gate>, Gate> originalData) {
// TODO actually support updates
// update operation not allowed -- restore the original config object and complain
@Override
protected void handleRemovedData(final Set<InstanceIdentifier<Gate>> removedPaths,
- final Map<InstanceIdentifier<Gate>, Gate> originalData) {
+ final Map<InstanceIdentifier<Gate>, Gate> originalData) {
for (final InstanceIdentifier<Gate> removedGateIID : removedPaths) {
final PCMMService service = pcmmServiceMap.get(thisCcap.getCcapId());
if (service != null) {
service.sendGateDelete(gatePathStr);
- logger.info("onDataChanged(): removed QoS gate {} for {}/{}/{}: ", gateId, ccapId, gatePathStr,
- thisGate);
+ logger.info("onDataChanged(): removed QoS gate {} for {}/{}/{}: ", gateId, ccapId, gatePathStr,thisGate);
} else {
logger.warn("Unable to send to locate PCMMService to send gate delete message with CCAP - "
+ thisCcap);
rpcResponse = gatePathStr + ": Subscriber ID not provided; gate poll not performed";
} else {
//poll all gates for the appId
+ PollAllGatesForApp pollAllGatesForApp = new PollAllGatesForApp(appIid,app);
+ Thread t = new Thread(pollAllGatesForApp);
+ t.start();
+ rpcResponse = appKey.getAppId() + "/: gate subtree poll in progress";
+ }
+ }
- Subscribers subs = app.getSubscribers();
+ DateAndTime rpcDateAndTime = getNowTimeStamp();
- logger.info("qospollgates subscribers: " + subs.toString());
+ QosPollGatesOutputBuilder outputBuilder = new QosPollGatesOutputBuilder().setTimestamp(rpcDateAndTime)
+ .setResponse(rpcResponse)
+ .setGate(gateOutputBuilder.build());
+ return Futures.immediateFuture(RpcResultBuilder.success(outputBuilder.build()).build());
+ }
+ private class PollAllGatesForApp implements Runnable {
- List<Subscriber> subList = subs.getSubscriber();
- logger.info("qospollgates subList: " + subList.toString());
- for (Subscriber sub : subList) {
+ private InstanceIdentifier <App> appIid;
+ private App app;
- //generate active subIid
- subscriberId = sub.getSubscriberId();
- InstanceIdentifier<Subscriber> subIid = appIid.builder()
- .child(Subscribers.class)
- .child(Subscriber.class, new SubscriberKey(subscriberId))
- .build();
+ private PollAllGatesForApp (InstanceIdentifier <App> appIid, App app) {
+ this.app = app;
+ this.appIid = appIid;
+ }
- List<Gate> gateList = sub.getGates().getGate();
- for (Gate gate : gateList) {
- //logger.info("qospollgates active gate: "+gate);
+ @Override
+ public void run() {
- //generate active gateIid
- gateId = gate.getGateId();
- InstanceIdentifier<Gate> gateIid =
- subIid.builder().child(Gates.class).child(Gate.class, new GateKey(gateId)).build();
+ org.opendaylight.yang.gen.v1.urn.packetcable.rev151101.qos.poll.gates.output.GateBuilder gateOutputBuilder =
+ new org.opendaylight.yang.gen.v1.urn.packetcable.rev151101.qos.poll.gates.output.GateBuilder();
- opsGate = readGateFromOperationalDatastore(gateIid);
- opsCopsGateId = opsGate.getCopsGateId();
- //generate active gatePathStr
- gatePathStr = appKey.getAppId() + "/" + subscriberId + "/" + gateId;
- if ((!Objects.equals(opsCopsGateId, "")) && (!Objects.equals(opsCopsGateId, null))) {
- ccapId = findCcapForSubscriberId(getInetAddress(subscriberId)).getCcapId();
- PCMMService pcmmService = pcmmServiceMap.get(ccapId);
- //is the CCAP socket open?
- if (!pcmmService.getPcmmPdpSocket() && pcmmService.getPcmmCcapClientIsConnected()) {
- PCMMService.GateSendStatus status = pcmmService.sendGateInfo(gatePathStr);
- DateAndTime gateDateAndTime = getNowTimeStamp();
- gateOutputError = Collections.singletonList(status.getMessage());
+ GateBuilder gateBuilder = new GateBuilder();
+ //generate appKey
+ AppKey appKey = InstanceIdentifier.keyOf(appIid);
- gateBuilder.setGateId(gateId)
- .setGatePath(gatePathStr)
- .setCcapId(ccapId)
- .setCopsGateState(
- status.getCopsGateState() + "/" + status.getCopsGateStateReason())
- .setCopsGateTimeInfo(status.getCopsGateTimeInfo())
- .setCopsGateUsageInfo(status.getCopsGateUsageInfo())
- .setCopsGateId(status.getCopsGateId())
- .setError(gateOutputError)
- .setTimestamp(gateDateAndTime);
+ Subscribers subs = app.getSubscribers();
+ logger.info("qospollgates subscribers: " + subs.toString());
- mdsalUtils.put(LogicalDatastoreType.OPERATIONAL, gateIid, gateBuilder.build());
- } else {
- logger.info(
- "qospollgates: {}: CCAP socket is down or client disconnected; gate poll not performed",
- ccapId);
- }
+ List<Subscriber> subList = subs.getSubscriber();
+ logger.info("qospollgates subList: " + subList.toString());
+
+ for (Subscriber sub : subList) {
+ //generate active subIid
+ String subscriberId = sub.getSubscriberId();
+ InstanceIdentifier<Subscriber> subIid = appIid.builder()
+ .child(Subscribers.class)
+ .child(Subscriber.class, new SubscriberKey(subscriberId))
+ .build();
+
+ List<Gate> gateList = sub.getGates().getGate();
+
+ for (Gate gate : gateList) {
+ //logger.info("qospollgates active gate: "+gate);
+
+ //generate active gateIid
+ String gateId = gate.getGateId();
+ InstanceIdentifier<Gate> gateIid =
+ subIid.builder().child(Gates.class).child(Gate.class, new GateKey(gateId)).build();
+
+
+ Gate opsGate = readGateFromOperationalDatastore(gateIid);
+ String opsCopsGateId = opsGate.getCopsGateId();
+ //generate active gatePathStr
+ String gatePathStr = appKey.getAppId() + "/" + subscriberId + "/" + gateId;
+
+ if ((!Objects.equals(opsCopsGateId, "")) && (!Objects.equals(opsCopsGateId, null))) {
+ String ccapId = findCcapForSubscriberId(getInetAddress(subscriberId)).getCcapId();
+ PCMMService pcmmService = pcmmServiceMap.get(ccapId);
+ //is the CCAP socket open?
+ if (!pcmmService.getPcmmPdpSocket() && pcmmService.getPcmmCcapClientIsConnected()) {
+ PCMMService.GateSendStatus status = pcmmService.sendGateInfo(gatePathStr);
+ DateAndTime gateDateAndTime = getNowTimeStamp();
+ List<String> gateOutputError = Collections.singletonList(status.getMessage());
+
+
+ gateBuilder.setGateId(gateId)
+ .setGatePath(gatePathStr)
+ .setCcapId(ccapId)
+ .setCopsGateState(
+ status.getCopsGateState() + "/" + status.getCopsGateStateReason())
+ .setCopsGateTimeInfo(status.getCopsGateTimeInfo())
+ .setCopsGateUsageInfo(status.getCopsGateUsageInfo())
+ .setCopsGateId(status.getCopsGateId())
+ .setError(gateOutputError)
+ .setTimestamp(gateDateAndTime);
+
+ mdsalUtils.put(LogicalDatastoreType.OPERATIONAL, gateIid, gateBuilder.build());
} else {
- //TODO define what happens if a gate is not active.. is nothing ok
- logger.info("qospollgates: {}: gate not active; gate poll not performed", gatePathStr);
+ logger.info(
+ "qospollgates: {}: CCAP socket is down or client disconnected; gate poll not performed",
+ ccapId);
}
+ } else {
+ //TODO define what happens if a gate is not active.. is nothing ok
+ logger.info("qospollgates: {}: gate not active; gate poll not performed", gatePathStr);
}
}
- rpcResponse = appKey.getAppId() + "/: gate subtree poll in progress";
}
}
- DateAndTime rpcDateAndTime = getNowTimeStamp();
-
- QosPollGatesOutputBuilder outputBuilder = new QosPollGatesOutputBuilder().setTimestamp(rpcDateAndTime)
- .setResponse(rpcResponse)
- .setGate(gateOutputBuilder.build());
- return Futures.immediateFuture(RpcResultBuilder.success(outputBuilder.build()).build());
}
+
private DateAndTime getNowTimeStamp() {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
return new DateAndTime(dateFormat.format(new Date()));
}
-}
+}
\ No newline at end of file