Removal of interfaces used by the packetcable-consumer bundle that has neither been... 46/20046/2
authorSteven Pisarski <s.pisarski@cablelabs.com>
Mon, 11 May 2015 17:54:31 +0000 (11:54 -0600)
committerSteve Pisarski <s.pisarski@cablelabs.com>
Tue, 12 May 2015 13:52:52 +0000 (13:52 +0000)
The each policy server instance connects to a CMTS but the gate control interfaces do not have any parameters to tell the CMTS which gates to set, delete, or query for the given CMTS. The implementation being removed (PCMMPolicyServer$PSCMTSClient) only supports a single gate per CMTS while multiple gates must be supported.

Change-Id: I094803732cbdd5f92b52e40ca742cfa36008d6f7
Signed-off-by: Steven Pisarski <s.pisarski@cablelabs.com>
packetcable-consumer/src/main/java/org/opendaylight/controller/config/yang/config/pcmm_service/impl/PcmmServiceModule.java
packetcable-consumer/src/main/java/org/opendaylight/controller/org/pcmm/impl/PcmmServiceImpl.java [deleted file]
packetcable-driver/src/main/java/org/pcmm/rcd/IPCMMPolicyServer.java [deleted file]
packetcable-driver/src/main/java/org/pcmm/rcd/impl/PCMMPolicyServer.java [deleted file]
packetcable-driver/src/test/java/org/pcmm/test/PCMMWorkflowTest.java [deleted file]

index e072369b7ecafb1f30fa69bcb7ed5c05e907e0f5..eb5dcbd3859e3d448c69d3735457b2fbf41b4c77 100644 (file)
@@ -7,11 +7,6 @@
  */
 package org.opendaylight.controller.config.yang.config.pcmm_service.impl;
 
-import org.opendaylight.controller.org.pcmm.api.PcmmService;
-import org.opendaylight.controller.org.pcmm.impl.PcmmServiceImpl;
-//import org.opendaylight.yang.gen.v1.urn.opendaylight.packetcable.service.rev140120.PacketcableServiceService;
-import org.opendaylight.yangtools.concepts.Registration;
-
 public class PcmmServiceModule
                extends
                org.opendaylight.controller.config.yang.config.pcmm_service.impl.AbstractPcmmServiceModule {
@@ -30,31 +25,7 @@ public class PcmmServiceModule
 
        @Override
        public java.lang.AutoCloseable createInstance() {
-               // PacketcableServiceService packetcableServiceService =
-               // getRpcRegistryDependency().getRpcService(PacketcableServiceService.class);
-               final PcmmService pcmmService = new PcmmServiceImpl();
-               final Registration pcmmListenerReg = getNotificationServiceDependency().registerNotificationListener(pcmmService);
-               final PcmmServiceRuntimeRegistration runtimeReg = getRootRuntimeBeanRegistratorWrapper().register(pcmmService);
-               return new AutoCloseablePcmmService(pcmmListenerReg, runtimeReg);
+               throw new UnsupportedOperationException("Implement me");
        }
 
-       class AutoCloseablePcmmService extends PcmmServiceImpl implements
-                       AutoCloseable {
-
-               private PcmmServiceRuntimeRegistration runtimeReg;
-               private Registration pcmmListenerReg;
-
-               public AutoCloseablePcmmService(Registration pcmmListenerReg, PcmmServiceRuntimeRegistration runtimeReg) {
-                       super();
-                       this.runtimeReg = runtimeReg;
-                       this.pcmmListenerReg = pcmmListenerReg;
-               }
-
-               @Override
-               public void close() throws Exception {
-                       pcmmListenerReg.close();
-                       runtimeReg.close();
-               }
-
-       }
 }
diff --git a/packetcable-consumer/src/main/java/org/opendaylight/controller/org/pcmm/impl/PcmmServiceImpl.java b/packetcable-consumer/src/main/java/org/opendaylight/controller/org/pcmm/impl/PcmmServiceImpl.java
deleted file mode 100644 (file)
index 663a941..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-package org.opendaylight.controller.org.pcmm.impl;
-
-import java.util.Iterator;
-import java.util.Map;
-
-import org.opendaylight.controller.org.pcmm.api.PcmmService;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.node.cmts.broker.rev140909.CmtsAdded;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.node.cmts.broker.rev140909.CmtsRemoved;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.node.cmts.broker.rev140909.CmtsUpdated;
-import org.pcmm.rcd.IPCMMPolicyServer;
-import org.pcmm.rcd.IPCMMPolicyServer.IPSCMTSClient;
-import org.pcmm.rcd.impl.PCMMPolicyServer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.Maps;
-
-public class PcmmServiceImpl implements PcmmService {
-
-       private static final Logger logger = LoggerFactory.getLogger(PcmmServiceImpl.class);
-       private Map<IpAddress, IPSCMTSClient> cmtsClients;
-       private IPCMMPolicyServer policyServer;
-
-       public PcmmServiceImpl() {
-               policyServer = new PCMMPolicyServer();
-               cmtsClients = Maps.newConcurrentMap();
-       }
-
-       @Override
-       public void onCmtsAdded(CmtsAdded notification) {
-               String ipv4 = notification.getAddress().getIpv4Address().getValue();
-               IPSCMTSClient client = policyServer.requestCMTSConnection(ipv4);
-               if (client.isConnected()) {
-                       cmtsClients.put(notification.getAddress(), client);
-               }
-       }
-
-       @Override
-       public void onCmtsRemoved(CmtsRemoved notification) {
-               if (cmtsClients.containsKey(notification.getAddress())) {
-                       IPSCMTSClient client = cmtsClients.remove(notification.getAddress());
-                       client.disconnect();
-               }
-       }
-
-       @Override
-       public void onCmtsUpdated(CmtsUpdated notification) {
-               // TODO
-       }
-
-       @Override
-       public Boolean sendGateDelete() {
-               // TODO change me
-               boolean ret = true;
-               for (Iterator<IPSCMTSClient> iter = cmtsClients.values().iterator(); iter.hasNext();)
-                       ret &= cmtsClients.get(0).gateDelete();
-               return ret;
-       }
-
-       @Override
-       public Boolean sendGateSynchronize() {
-               boolean ret = true;
-               for (Iterator<IPSCMTSClient> iter = cmtsClients.values().iterator(); iter.hasNext();)
-                       ret &= cmtsClients.get(0).gateSynchronize();
-               return ret;
-       }
-
-       @Override
-       public Boolean sendGateInfo() {
-               boolean ret = true;
-               for (Iterator<IPSCMTSClient> iter = cmtsClients.values().iterator(); iter.hasNext();)
-                       ret &= cmtsClients.get(0).gateInfo();
-               return ret;
-       }
-
-       @Override
-       public Boolean sendGateSet() {
-               boolean ret = true;
-               for (Iterator<IPSCMTSClient> iter = cmtsClients.values().iterator(); iter.hasNext();)
-                       ret &= cmtsClients.get(0).gateSet();
-               return ret;
-       }
-}
diff --git a/packetcable-driver/src/main/java/org/pcmm/rcd/IPCMMPolicyServer.java b/packetcable-driver/src/main/java/org/pcmm/rcd/IPCMMPolicyServer.java
deleted file mode 100644 (file)
index b23c83e..0000000
+++ /dev/null
@@ -1,222 +0,0 @@
-/**
- @header@
- */
-
-package org.pcmm.rcd;
-
-import java.net.InetAddress;
-
-import org.pcmm.objects.MMVersionInfo;
-import org.pcmm.state.IStateful;
-
-/**
- * <i>PKT-SP-MM-I05-091029 PacketCableTM Specification</i>
- * <p>
- * As discussed in RFC 2753 [11], the policy management framework underlying
- * PacketCable Multimedia is based on the work of the IETF's Resource Allocation
- * Protocol (RAP) working group. Since the Policy Server is situated between the
- * Application Manager and the CMTS, it simultaneously plays a dual role as a
- * "proxy" for AM-initiated session requests and as a "sentry" for defining and
- * enforcing Resource Control Domain policy. As described in [11] and in keeping
- * with the PacketCable 1.x DQoS model, the Policy Server serves as Policy
- * Decision Point (PDP) in relation to the CMTS in that the Policy Server
- * implements MSO-defined authorization and resource-management procedures.
- * Conversely, the Policy Server assumes the role of Policy Enforcement Point
- * (PEP) in relation to the Application Manager as it proxies Gate Control
- * messages to and from the CMTS element. To revisit the interaction scenario,
- * the Application Manager issues policy requests to the Policy Server. The
- * Policy Server acting as a "sentry" for these requests, and applies a set of
- * policy rules that have been pre-provisioned by the MSO. Upon passing the
- * checks, the Policy Server then acts as a "proxy" with respect to the
- * Application Manager and the CMTS, forwarding the policy request and returning
- * any associated response. Each policy request transaction must be processed
- * individually. Policy decisions may be based on a number of factors, such as:
- * <ul>
- * <li>Parameters associated with the request and the status of available
- * resources</li>
- * <li>Identity of the particular client and associated profile information</li>
- * <li>Application parameters</li>
- * <li>Security considerations</li>
- * <li>Time-of-day</li>
- * </ul>
- * The primary functions of the Policy Server include:
- * <ul>
- * <li>A policy decision request mechanism, invoked by Application Managers</li>
- * <li>A policy decision request 'policing' mechanism, enforcing installed
- * Policy Rules</li>
- * <li>A policy decision delivery mechanism, used to install policy decisions on
- * the CMTS</li>
- * <li>A mechanism to allow for the proxying of QoS management messages to the
- * CMTS on behalf of the Application Manager</li>
- * <li>An event recording interface to a Record Keeping Server that is used to
- * log policy requests, which may in turn be correlated with network resource
- * usage records</li>·
- * </ul>
- * Since the Policy Server functions as a proxy between the AM and CMTS elements
- * (with complementary client and server interfaces) some MSOs may elect to
- * deploy multiple layers of Policy Servers and to delegate certain policy
- * decisions among these servers in order to satisfy requirements associated
- * with scalability and fault-tolerance.
- * </p>
- * <p>
- * <i>Stateful & Stateless Policy Servers</i> There are two basic classes of
- * Policy Servers – Stateful and Stateless. A Stateless Policy Server is a
- * slight misnomer since it does maintain enough state to map Application
- * Manager requests to the proper CMTS and maintain COPS session state, while a
- * pure Stateless Policy Server maintains no state on any of the media sessions.
- * Stateful Policy Servers come in several varieties – some participate in
- * admission control and thus monitor the QoS attributes of active media
- * sessions, some leave QoS and admission control to the CMTS but monitor
- * time-based or volume-based service requests from the Application Manager, and
- * some Policy Servers are somewhere between these extremes. The reason there is
- * a variety of Policy Server types is that there is a variety of environments
- * that operators are trying to support. For example, some operators may wish to
- * support PacketCable Multimedia over the same CMTSs that they use for
- * PacketCable telephony, and they may want a single CMS/Policy Server that has
- * a more global view of the network resources being used. On the other hand,
- * some operators may wish to run a PacketCable Multimedia- only environment, or
- * they may utilize simpler CMTS-driven mechanisms for partitioning PacketCable
- * Multimedia and telephony resources. These simpler configurations have more
- * modest requirements on the amount of state that a Policy Server maintains.
- * Policy Server state requirements can also be driven by the level of trust
- * between the Policy Server and Application Manager; a Stateful Policy Server
- * can more readily police Application Manager session control behavior than can
- * a Stateless Policy Server. So a Stateful Policy Server may be more
- * appropriate for operators supporting third party Application Managers. Other
- * operators may rely on economics to enforce their trust relationships with
- * Application Managers, or they may control the Application Managers
- * themselves. In such cases a Stateless Policy Server may be more appropriate.
- * Since it is impossible to categorize all the various components of media
- * session and network QoS state that a Policy Server is maintaining, the
- * protocol is designed to be independent of this complexity. A Stateful Policy
- * Server gleans PacketCable Multimedia media session information from the
- * Application Manager requests it proxies; any other information it requires is
- * gathered via mechanisms that are outside the scope of this specification. The
- * CMTS and the Application Manager make no distinction as to the type of Policy
- * Server to which they are connected, and the protocol is designed in such a
- * manner that the type of Policy Server is transparent to the end point. The
- * type of Policy Server is only of importance to the operator. Since some types
- * of Policy Servers attempt to assist with admission control and may have a
- * larger view of the network and its resources, additional state
- * synchronization issues may arise in design in a network which contains more
- * than one of these types of Policy Servers. It is the responsibility of the
- * operator to ensure that the efforts of these Policy Servers are not
- * undermined by a network that includes other autonomous Policy Servers.
- * </p>
- * <p>
- * <i>Modification of Requests and Responses by Policy Servers</i> Although
- * nominally a part of the Resource Control Domain, the Policy Server can be an
- * intermediary between the Service and the Resource Control Domains, in
- * addition to its normal role of implementing MSO-defined authorization and
- * resource management procedures. In either of these capacities it may modify
- * the incoming request before forwarding it to the CMTS. In acting as an
- * intermediary between the SCD and RCD, the Policy Server may translate fields
- * from formats or scales used in the SCD into formats or scales used in the
- * RCD. For example, the Policy Server may modify the "priority" of a request
- * coming from an Application Manager (especially important to do for an AM
- * outside of the MSO network) so that this priority field uses a consistent
- * scale throughout the operator's RCD. In its capacity as an intermediary, the
- * Policy Server may use bidirectional translation – in other words, it should
- * translate requests from the AM to the CMTS and "untranslate" the responses
- * from the CMTS to the AM. This capability can be supported by stateful policy
- * servers by remembering the original request, and it can be supported by
- * stateless Policy Servers if the translation function is invertible.
- * Modification of certain objects, specifically the Classifier and Traffic
- * Profile objects, may cause operational problems in the originating AM. As
- * such, these objects MUST NOT be modified by the policy server. Aside from
- * these exceptions, all other objects may be policed and modified at the PS's
- * discretion based on provisioned policy rules.
- * </p>
- * 
- */
-public interface IPCMMPolicyServer extends IPCMMServer, IStateful {
-
-       /**
-        * establishes COPS connection with the CMTS
-        * 
-        * @param host
-        *            : remote host name or ip address
-        * @return connected socket.
-        */
-       IPSCMTSClient requestCMTSConnection(String host);
-
-       /**
-        * establishes COPS connection with the CMTS
-        * 
-        * @param host
-        *            : remote ip address‚
-        * @return connected socket.
-        */
-       IPSCMTSClient requestCMTSConnection(InetAddress host);
-
-       /**
-        * <p>
-        * In the PacketCable model, the CMTS (PEP) is the one that listens on the
-        * assigned port 3918, and it is the Policy Server that MUST initiate the
-        * TCP connection to the CMTS, thus we implement the IPCMMClient interface.
-        * </p>
-        */
-       public static interface IPSCMTSClient extends IPCMMClient {
-
-               /**
-                * 
-                * @return Classifier Id.
-                */
-               short getClassifierId();
-
-               /**
-                * 
-                * @return the transaction Id.
-                */
-               short getTransactionId();
-
-               /**
-                * Gate id transmitted by the CMTS to the PS.
-                * 
-                * @return the Gate Id.
-                */
-               int getGateId();
-
-               /**
-                * initiates a Gate-Set with the CMTS
-                * 
-                * @return
-                */
-               boolean gateSet();
-
-               /**
-                * initiates a Gate-Info with the CMTS
-                * 
-                * @return
-                */
-               boolean gateInfo();
-
-               /**
-                * initiates a Gate-Delete with the CMTS
-                * 
-                * @return
-                */
-               boolean gateDelete();
-
-               /**
-                * sends synch request
-                * 
-                * @return
-                */
-               boolean gateSynchronize();
-
-               /**
-                * Sets the value of the multi-media version info.
-                * 
-                * @param MM
-                *            version info
-                */
-               void setVersionInfo(MMVersionInfo vInfo);
-
-               /**
-                * 
-                * @return MM version info
-                */
-               MMVersionInfo getVersionInfo();
-       }
-}
diff --git a/packetcable-driver/src/main/java/org/pcmm/rcd/impl/PCMMPolicyServer.java b/packetcable-driver/src/main/java/org/pcmm/rcd/impl/PCMMPolicyServer.java
deleted file mode 100644 (file)
index 8c31270..0000000
+++ /dev/null
@@ -1,658 +0,0 @@
-/**
- * @header@
- */
-package org.pcmm.rcd.impl;
-
-import org.pcmm.PCMMConstants;
-import org.pcmm.PCMMGlobalConfig;
-import org.pcmm.PCMMProperties;
-import org.pcmm.gates.*;
-import org.pcmm.gates.IGateSpec.DSCPTOS;
-import org.pcmm.gates.IGateSpec.Direction;
-import org.pcmm.gates.impl.*;
-import org.pcmm.messages.IMessage.MessageProperties;
-import org.pcmm.messages.impl.MessageFactory;
-import org.pcmm.objects.MMVersionInfo;
-import org.pcmm.rcd.IPCMMPolicyServer;
-import org.pcmm.utils.PCMMException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.umu.cops.prpdp.COPSPdpConnection;
-import org.umu.cops.prpdp.COPSPdpDataProcess;
-import org.umu.cops.stack.*;
-import org.umu.cops.stack.COPSDecision.Command;
-import org.umu.cops.stack.COPSHeader.OPCode;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.net.UnknownHostException;
-import java.util.Properties;
-
-/**
- * PCMM policy server
- */
-public class PCMMPolicyServer extends AbstractPCMMServer implements IPCMMPolicyServer {
-
-    public final static Logger logger = LoggerFactory.getLogger(PCMMPolicyServer.class);
-
-    /**
-     * since PCMMPolicyServer can connect to multiple CMTS (PEP) we need to
-     * manage each connection in a separate thread.
-     */
-
-    public PCMMPolicyServer() {
-        super();
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.pcmm.rcd.IPCMMPolicyServer#requestCMTSConnection(java.lang.String)
-     */
-    public IPSCMTSClient requestCMTSConnection(String host) {
-        try {
-            InetAddress address = InetAddress.getByName(host);
-            return requestCMTSConnection(address);
-        } catch (UnknownHostException e) {
-            logger.error(e.getMessage());
-        }
-        return null;
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.pcmm.rcd.IPCMMPolicyServer#requestCMTSConnection(java.net.InetAddress
-     * )
-     */
-    public IPSCMTSClient requestCMTSConnection(InetAddress host) {
-        IPSCMTSClient client = new PSCMTSClient();
-        try {
-            if (client.tryConnect(host, PCMMProperties.get(PCMMConstants.PCMM_PORT, Integer.class))) {
-                boolean endNegotiation = false;
-                while (!endNegotiation) {
-                    logger.debug("waiting for OPN message from CMTS");
-                    COPSMsg opnMessage = client.readMessage();
-                    // Client-Close
-                    if (opnMessage.getHeader().getOpCode().equals(OPCode.CC)) {
-                        COPSError error = ((COPSClientCloseMsg) opnMessage).getError();
-                        logger.debug("CMTS requetsed Client-Close");
-                        throw new PCMMException(new PCMMError((short)error.getErrCode().ordinal(),
-                                (short)error.getErrSubCode().ordinal()));
-                    } else // Client-Open
-                    {
-                        if (opnMessage.getHeader().getOpCode().equals(OPCode.OPN)) {
-                            logger.debug("OPN message received from CMTS");
-                            COPSClientOpenMsg opn = (COPSClientOpenMsg) opnMessage;
-                            if (opn.getClientSI() == null) {
-                                throw new COPSException("CMTS shoud have sent MM version info in Client-Open message");
-                            } else {
-                                // set the version info
-                                MMVersionInfo vInfo = new MMVersionInfo(opn.getClientSI().getData().getData());
-                                client.setVersionInfo(vInfo);
-                                logger.debug(
-                                        "CMTS sent MMVersion info : major:" + vInfo.getMajorVersionNB() + "  minor:" +
-                                                vInfo.getMinorVersionNB()); //
-                                if (client.getVersionInfo().getMajorVersionNB() ==
-                                        client.getVersionInfo().getMinorVersionNB()) {
-                                    // send a CC since CMTS has exhausted all
-                                    // protocol selection attempts
-                                    throw new COPSException("CMTS exhausted all protocol selection attempts");
-                                }
-                            }
-                            // send CAT response
-                            Properties prop = new Properties();
-                            logger.debug("send CAT to the CMTS ");
-                            COPSMsg catMsg = MessageFactory.getInstance().create(OPCode.CAT, prop);
-                            client.sendRequest(catMsg);
-                            // wait for REQ msg
-                            COPSMsg reqMsg = client.readMessage();
-                            // Client-Close
-                            if (reqMsg.getHeader().getOpCode().equals(OPCode.CC)) {
-                                COPSError error = ((COPSClientCloseMsg) opnMessage).getError();
-                                logger.debug("CMTS requetsed Client-Close");
-                                throw new PCMMException(new PCMMError((short)error.getErrCode().ordinal(),
-                                        (short)error.getErrSubCode().ordinal()));
-                            } else // Request
-                            {
-                                if (reqMsg.getHeader().getOpCode().equals(OPCode.REQ)) {
-                                    logger.debug("Received REQ message form CMTS");
-                                    // end connection attempts
-                                    COPSReqMsg req = (COPSReqMsg) reqMsg;
-                                    // set the client handle to be used later by the
-                                    // gate-set
-                                    client.setClientHandle(req.getClientHandle().getId().str());
-                                    COPSPdpDataProcess processor = null;
-                                    COPSPdpConnection copsPdpConnection = new COPSPdpConnection(opn.getPepId(),
-                                            ((AbstractPCMMClient) client).getSocket(), processor);
-                                    copsPdpConnection
-                                            .setKaTimer(((COPSClientAcceptMsg) catMsg).getKATimer().getTimerVal());
-                                    pool.schedule(pool.adapt(copsPdpConnection));
-                                    endNegotiation = true;
-                                } else {
-                                    throw new COPSException("Can't understand request");
-                                }
-                            }
-                        } else {
-                            throw new COPSException("Can't understand request");
-                        }
-                    }
-                }
-            }
-            // else raise exception.
-        } catch (Exception e) {
-            logger.error(e.getMessage());
-            // no need to keep connection.
-            client.disconnect();
-            return null;
-        }
-        return client;
-    }
-
-    @Override
-    protected IPCMMClientHandler getPCMMClientHandler(Socket socket) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    /**
-     * @see {@link IPSCMTSClient}
-     */
-    /* public */static class PSCMTSClient extends AbstractPCMMClient implements IPSCMTSClient {
-        /**
-         * Transaction id is
-         */
-        private short transactionID;
-        private short classifierID;
-        private int gateID;
-
-        public PSCMTSClient() {
-            super();
-            logger.info("Client " + getClass() + hashCode() + " crated and started");
-        }
-
-        public PSCMTSClient(Socket socket) {
-            setSocket(socket);
-        }
-
-        public boolean gateSet() {
-            logger.debug("Sending Gate-Set message");
-            if (!isConnected()) {
-                throw new IllegalArgumentException("Not connected");
-            }
-            // XXX check if other values should be provided
-            //
-            ITrafficProfile trafficProfile = buildTrafficProfile();
-            // PCMMGlobalConfig.DefaultBestEffortTrafficRate);
-            ITransactionID trID = new TransactionID();
-            // set transaction ID to gate set
-            trID.setGateCommandType(ITransactionID.GateSet);
-            transactionID = (transactionID == 0 ? (short) (Math.random() * hashCode()) : transactionID);
-            trID.setTransactionIdentifier(transactionID);
-            // AMID
-            IAMID amid = getAMID();
-            // GATE SPEC
-            IGateSpec gateSpec = getGateSpec();
-            ISubscriberID subscriberID = new SubscriberID();
-            // Classifier if MM version <4, Extended Classifier else
-            IClassifier eclassifier = getClassifier(subscriberID);
-
-            IPCMMGate gate = new PCMMGateReq();
-            gate.setTransactionID(trID);
-            gate.setAMID(amid);
-            gate.setSubscriberID(subscriberID);
-            gate.setGateSpec(gateSpec);
-            gate.setTrafficProfile(trafficProfile);
-            gate.setClassifier(eclassifier);
-            byte[] data = gate.getData();
-
-            // configure message properties
-            Properties prop = new Properties();
-            prop.put(MessageProperties.CLIENT_HANDLE, getClientHandle());
-            prop.put(MessageProperties.DECISION_CMD_CODE, Command.INSTALL);
-            prop.put(MessageProperties.DECISION_FLAG, Command.NULL);
-            prop.put(MessageProperties.GATE_CONTROL, new COPSData(data, 0, data.length));
-            COPSMsg decisionMsg = MessageFactory.getInstance().create(OPCode.DEC, prop);
-            // ** Send the GateSet Decision
-            // **
-            sendRequest(decisionMsg);
-            // TODO check on this ?
-            // waits for the gate-set-ack or error
-            COPSMsg responseMsg = readMessage();
-            if (responseMsg.getHeader().getOpCode().equals(OPCode.RPT)) {
-                logger.info("processing received report from CMTS");
-                COPSReportMsg reportMsg = (COPSReportMsg) responseMsg;
-                if (reportMsg.getClientSI() == null) {
-                    logger.debug("CMTS responded with an empty SI");
-                    return false;
-                }
-                COPSClientSI clientSI = reportMsg.getClientSI();
-                IPCMMGate responseGate = new PCMMGateReq(clientSI.getData().getData());
-                IPCMMError error = responseGate.getError();
-                if (error != null) {
-                    logger.error(error.toString());
-                    return false;
-                }
-                logger.info("the CMTS has sent TransactionID :" + responseGate.getTransactionID());
-                if (responseGate.getTransactionID() != null &&
-                        responseGate.getTransactionID().getGateCommandType() == ITransactionID.GateSetAck) {
-                    logger.info("the CMTS has sent a Gate-Set-Ack response");
-                    // here CMTS responded that he acknowledged the Gate-Set
-                    // TODO do further check of Gate-Set-Ack GateID etc...
-                    gateID = responseGate.getGateID().getGateID();
-                    return true;
-                } else {
-                    return false;
-                }
-            }
-            return false;
-        }
-
-        /*
-         * (non-Javadoc)
-         *
-         * @see org.pcmm.rcd.IPCMMPolicyServer#gateDelete()
-         */
-        @Override
-        public boolean gateDelete() {
-            if (!isConnected()) {
-                logger.error("Not connected");
-                return false;
-            }
-            ITransactionID trID = new TransactionID();
-            // set transaction ID to gate set
-            trID.setGateCommandType(ITransactionID.GateDelete);
-            trID.setTransactionIdentifier(transactionID);
-            // AMID
-            IAMID amid = getAMID();
-            // GATE SPEC
-            ISubscriberID subscriberID = new SubscriberID();
-            try {
-                subscriberID.setSourceIPAddress(InetAddress.getLocalHost());
-            } catch (UnknownHostException e1) {
-                logger.error(e1.getMessage());
-            }
-
-            IGateID gateIdObj = new GateID();
-            gateIdObj.setGateID(gateID);
-
-            IPCMMGate gate = new PCMMGateReq();
-            gate.setTransactionID(trID);
-            gate.setAMID(amid);
-            gate.setSubscriberID(subscriberID);
-            gate.setGateID(gateIdObj);
-
-            // configure message properties
-            Properties prop = new Properties();
-            prop.put(MessageProperties.CLIENT_HANDLE, getClientHandle());
-            prop.put(MessageProperties.DECISION_CMD_CODE, Command.INSTALL);
-            prop.put(MessageProperties.DECISION_FLAG, Command.NULL);
-            byte[] data = gate.getData();
-            prop.put(MessageProperties.GATE_CONTROL, new COPSData(data, 0, data.length));
-            COPSMsg decisionMsg = MessageFactory.getInstance().create(OPCode.DEC, prop);
-            // ** Send the GateSet Decision
-            // **
-            try {
-                decisionMsg.writeData(getSocket());
-            } catch (IOException e) {
-                logger.error("Failed to send the decision, reason: " + e.getMessage());
-                return false;
-            }
-            // waits for the gate-delete-ack or error
-            COPSMsg responseMsg = readMessage();
-            if (responseMsg.getHeader().getOpCode().equals(OPCode.RPT)) {
-                logger.info("processing received report from CMTS");
-                COPSReportMsg reportMsg = (COPSReportMsg) responseMsg;
-                if (reportMsg.getClientSI() == null) {
-                    return false;
-                }
-                COPSClientSI clientSI = reportMsg.getClientSI();
-                IPCMMGate responseGate = new PCMMGateReq(clientSI.getData().getData());
-                IPCMMError error = responseGate.getError();
-                if (error != null) {
-                    logger.error(error.toString());
-                    return false;
-                }
-                // here CMTS responded that he acknowledged the Gate-delete
-                // message
-                ITransactionID responseTransactionID = responseGate.getTransactionID();
-                if (responseTransactionID != null &&
-                        responseTransactionID.getGateCommandType() == ITransactionID.GateDeleteAck) {
-                    // TODO check : Is this test needed ??
-                    if (responseGate.getGateID().getGateID() == gateID &&
-                            responseTransactionID.getTransactionIdentifier() == transactionID) {
-                        logger.info("the CMTS has sent a Gate-Delete-Ack response");
-                        return true;
-                    }
-                }
-
-            }
-            return false;
-        }
-
-        /*
-         * (non-Javadoc)
-         *
-         * @see org.pcmm.rcd.IPCMMPolicyServer#gateInfo()
-         */
-        @Override
-        public boolean gateInfo() {
-            if (!isConnected()) {
-                logger.error("Not connected");
-                return false;
-            }
-            ITransactionID trID = new TransactionID();
-            // set transaction ID to gate set
-            trID.setGateCommandType(ITransactionID.GateInfo);
-            trID.setTransactionIdentifier(transactionID);
-            // AMID
-            IAMID amid = getAMID();
-            // GATE SPEC
-            ISubscriberID subscriberID = new SubscriberID();
-            try {
-                subscriberID.setSourceIPAddress(InetAddress.getLocalHost());
-            } catch (UnknownHostException e1) {
-                logger.error(e1.getMessage());
-            }
-            IGateID gateIdObj = new GateID();
-            gateIdObj.setGateID(gateID);
-
-            IPCMMGate gate = new PCMMGateReq();
-            gate.setTransactionID(trID);
-            gate.setAMID(amid);
-            gate.setSubscriberID(subscriberID);
-            gate.setGateID(gateIdObj);
-
-            // configure message properties
-            Properties prop = new Properties();
-            prop.put(MessageProperties.CLIENT_HANDLE, getClientHandle());
-            prop.put(MessageProperties.DECISION_CMD_CODE, Command.INSTALL);
-            prop.put(MessageProperties.DECISION_FLAG, Command.NULL);
-            byte[] data = gate.getData();
-            prop.put(MessageProperties.GATE_CONTROL, new COPSData(data, 0, data.length));
-            COPSMsg decisionMsg = MessageFactory.getInstance().create(OPCode.DEC, prop);
-            // ** Send the GateSet Decision
-            // **
-            try {
-                decisionMsg.writeData(getSocket());
-            } catch (IOException e) {
-                logger.error("Failed to send the decision, reason: " + e.getMessage());
-                return false;
-            }
-            // waits for the gate-Info-ack or error
-            COPSMsg responseMsg = readMessage();
-            if (responseMsg.getHeader().getOpCode().equals(OPCode.RPT)) {
-                logger.info("processing received report from CMTS");
-                COPSReportMsg reportMsg = (COPSReportMsg) responseMsg;
-                if (reportMsg.getClientSI() == null) {
-                    return false;
-                }
-                COPSClientSI clientSI = reportMsg.getClientSI();
-                IPCMMGate responseGate = new PCMMGateReq(clientSI.getData().getData());
-                IPCMMError error = responseGate.getError();
-                ITransactionID responseTransactionID = responseGate.getTransactionID();
-                if (error != null) {
-                    logger.debug(responseTransactionID != null ? responseTransactionID.toString() :
-                            "returned Transaction ID is null");
-                    logger.error(error.toString());
-                    return false;
-                }
-                // here CMTS responded that he acknowledged the Gate-Info
-                // message
-                /*
-                 * <Gate-Info-Ack> = <ClientSI Header> <TransactionID> <AMID>
-                 * <SubscriberID> <GateID> [<Event Generation Info>] <Gate-Spec>
-                 * <classifier> <classifier...>] <Traffic Profile> <Gate Time
-                 * Info> <Gate Usage Info> [<Volume-Based Usage Limit>] [<PSID>]
-                 * [<Msg-Receipt-Key>] [<UserID>] [<Time-Based Usage Limit>]
-                 * [<Opaque Data>] <GateState> [<SharedResourceID>]
-                 */
-                if (responseTransactionID != null &&
-                        responseTransactionID.getGateCommandType() == ITransactionID.GateInfoAck) {
-                    // TODO need to implement missing data wrapper
-                    logger.info("TransactionID : " + responseTransactionID.toString());
-                    logger.info("AMID :" + String.valueOf(responseGate.getAMID()));
-                    logger.info("SubscriberID :" + String.valueOf(responseGate.getSubscriberID()));
-                    logger.info("Traffic Profile :" + String.valueOf(responseGate.getTrafficProfile()));
-                    logger.info("Gate Time Info :");
-                    logger.info("Gate Usage Info :");
-                    logger.info("GateState :");
-                    return true;
-                }
-
-            }
-            return false;
-        }
-
-        /*
-         * (non-Javadoc)
-         *
-         * @see org.pcmm.rcd.IPCMMPolicyServer#synchronize()
-         */
-        @Override
-        public boolean gateSynchronize() {
-            if (!isConnected()) {
-                logger.error("Not connected");
-                return false;
-            }
-            ITransactionID trID = new TransactionID();
-            // set transaction ID to gate set
-            trID.setGateCommandType(ITransactionID.SynchRequest);
-            trID.setTransactionIdentifier(transactionID);
-            // AMID
-            IAMID amid = getAMID();
-            // GATE SPEC
-            ISubscriberID subscriberID = new SubscriberID();
-            try {
-                subscriberID.setSourceIPAddress(InetAddress.getLocalHost());
-            } catch (UnknownHostException e1) {
-                logger.error(e1.getMessage());
-            }
-            IGateID gateIdObj = new GateID();
-            gateIdObj.setGateID(gateID);
-
-            IPCMMGate gate = new PCMMGateReq();
-            gate.setTransactionID(trID);
-            gate.setAMID(amid);
-            gate.setSubscriberID(subscriberID);
-            gate.setGateID(gateIdObj);
-
-            // configure message properties
-            Properties prop = new Properties();
-            prop.put(MessageProperties.CLIENT_HANDLE, getClientHandle());
-            prop.put(MessageProperties.DECISION_CMD_CODE, Command.INSTALL);
-            prop.put(MessageProperties.DECISION_FLAG, Command.NULL);
-            byte[] data = gate.getData();
-            prop.put(MessageProperties.GATE_CONTROL, new COPSData(data, 0, data.length));
-            COPSMsg decisionMsg = MessageFactory.getInstance().create(OPCode.DEC, prop);
-            // ** Send the GateSet Decision
-            // **
-            try {
-                decisionMsg.writeData(getSocket());
-            } catch (IOException e) {
-                logger.error("Failed to send the decision, reason: " + e.getMessage());
-                return false;
-            }
-            // waits for the gate-Info-ack or error
-            COPSMsg responseMsg = readMessage();
-            if (responseMsg.getHeader().getOpCode().equals(OPCode.RPT)) {
-                logger.info("processing received report from CMTS");
-                COPSReportMsg reportMsg = (COPSReportMsg) responseMsg;
-                if (reportMsg.getClientSI() == null) {
-                    return false;
-                }
-                COPSClientSI clientSI = reportMsg.getClientSI();
-                IPCMMGate responseGate = new PCMMGateReq(clientSI.getData().getData());
-                IPCMMError error = responseGate.getError();
-                ITransactionID responseTransactionID = responseGate.getTransactionID();
-                if (error != null) {
-                    logger.debug(responseTransactionID != null ? responseTransactionID.toString() :
-                            "returned Transaction ID is null");
-                    logger.error(error.toString());
-                    return false;
-                }
-                // here CMTS responded that he acknowledged the Gate-Info
-                // message
-                /*
-                 * <Gate-Info-Ack> = <ClientSI Header> <TransactionID> <AMID>
-                 * <SubscriberID> <GateID> [<Event Generation Info>] <Gate-Spec>
-                 * <classifier> <classifier...>] <Traffic Profile> <Gate Time
-                 * Info> <Gate Usage Info> [<Volume-Based Usage Limit>] [<PSID>]
-                 * [<Msg-Receipt-Key>] [<UserID>] [<Time-Based Usage Limit>]
-                 * [<Opaque Data>] <GateState> [<SharedResourceID>]
-                 */
-                if (responseTransactionID != null &&
-                        responseTransactionID.getGateCommandType() == ITransactionID.SynchReport) {
-                    // TODO need to implement missing data wrapper
-                    logger.info("TransactionID : " + responseTransactionID.toString());
-                    logger.info("AMID :" + String.valueOf(responseGate.getAMID()));
-                    logger.info("SubscriberID :" + String.valueOf(responseGate.getSubscriberID()));
-                    logger.info("Traffic Profile :" + String.valueOf(responseGate.getTrafficProfile()));
-                    logger.info("Gate Time Info :");
-                    logger.info("Gate Usage Info :");
-                    logger.info("GateState :");
-                    return true;
-                }
-
-            }
-            return false;
-        }
-
-        private IAMID getAMID() {
-            IAMID amid = new AMID();
-            amid.setApplicationType((short) 1);
-            amid.setApplicationMgrTag((short) 1);
-            return amid;
-        }
-
-        private IClassifier getClassifier(ISubscriberID subscriberID) {
-            IClassifier classifier;
-            // if the version major is less than 4 we need to use Classifier
-            if (getVersionInfo().getMajorVersionNB() >= 4) {
-                classifier = new ExtendedClassifier();
-                // eclassifier.setProtocol(IClassifier.Protocol.NONE);
-//                classifier.setProtocol(IClassifier.Protocol.TCP);
-                try {
-                    InetAddress subIP = InetAddress.getByName(PCMMGlobalConfig.SubscriberID);
-                    InetAddress srcIP = InetAddress.getByName(PCMMGlobalConfig.srcIP);
-                    InetAddress dstIP = InetAddress.getByName(PCMMGlobalConfig.dstIP);
-                    InetAddress mask =
-                            InetAddress.getByName(PCMMProperties.get(PCMMConstants.DEFAULT_MASK, String.class));
-                    subscriberID.setSourceIPAddress(subIP);
-                    classifier.setSourceIPAddress(srcIP);
-                    classifier.setDestinationIPAddress(dstIP);
-                    ((IExtendedClassifier) classifier).setIPDestinationMask(mask);
-                    ((IExtendedClassifier) classifier).setIPSourceMask(mask);
-                } catch (UnknownHostException unae) {
-                    logger.error("Error getByName", unae);
-                }
-                ((IExtendedClassifier) classifier).setSourcePortStart(PCMMGlobalConfig.srcPort);
-                ((IExtendedClassifier) classifier).setSourcePortEnd(PCMMGlobalConfig.srcPort);
-                ((IExtendedClassifier) classifier).setDestinationPortStart(PCMMGlobalConfig.dstPort);
-                ((IExtendedClassifier) classifier).setDestinationPortEnd(PCMMGlobalConfig.dstPort);
-                ((IExtendedClassifier) classifier).setActivationState((byte) 0x01);
-                /*
-                 * check if we have a stored value of classifierID else we just
-                 * create one eclassifier.setClassifierID((short) 0x01);
-                 */
-                ((IExtendedClassifier) classifier)
-                        .setClassifierID((short) (classifierID == 0 ? Math.random() * hashCode() : classifierID));
-                // XXX - testie
-                // eclassifier.setClassifierID((short) 1);
-                ((IExtendedClassifier) classifier).setAction((byte) 0x00);
-                // XXX - temp default until Gate Modify is hacked in
-                // eclassifier.setPriority(PCMMGlobalConfig.EClassifierPriority);
-                classifier.setPriority((byte) 65);
-
-            } else {
-                classifier = new Classifier();
-//                classifier.setProtocol(IClassifier.Protocol.TCP);
-                try {
-                    InetAddress subIP = InetAddress.getByName(PCMMGlobalConfig.SubscriberID);
-                    InetAddress srcIP = InetAddress.getByName(PCMMGlobalConfig.srcIP);
-                    InetAddress dstIP = InetAddress.getByName(PCMMGlobalConfig.dstIP);
-                    subscriberID.setSourceIPAddress(subIP);
-                    classifier.setSourceIPAddress(srcIP);
-                    classifier.setDestinationIPAddress(dstIP);
-                } catch (UnknownHostException unae) {
-                    logger.error("Error getByName", unae);
-                }
-                classifier.setSourcePort(PCMMGlobalConfig.srcPort);
-                classifier.setDestinationPort(PCMMGlobalConfig.dstPort);
-            }
-            return classifier;
-        }
-
-        /**
-         * @return GateSpec object
-         */
-        private IGateSpec getGateSpec() {
-            IGateSpec gateSpec = new GateSpec();
-            gateSpec.setDirection(Direction.UPSTREAM);
-            gateSpec.setDSCP_TOSOverwrite(DSCPTOS.OVERRIDE);
-            gateSpec.setTimerT1(PCMMGlobalConfig.GateT1);
-            gateSpec.setTimerT2(PCMMGlobalConfig.GateT2);
-            gateSpec.setTimerT3(PCMMGlobalConfig.GateT3);
-            gateSpec.setTimerT4(PCMMGlobalConfig.GateT4);
-            return gateSpec;
-        }
-
-        /**
-         * creates a traffic profile with 3 envelops (Authorized, Reserved and
-         * Committed).
-         *
-         * @return Traffic profile
-         */
-        private ITrafficProfile buildTrafficProfile() {
-            ITrafficProfile trafficProfile = new BestEffortService(BestEffortService.DEFAULT_ENVELOP);
-            ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
-                    .setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
-            ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
-                    .setMaximumTrafficBurst(BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
-            ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
-                    .setRequestTransmissionPolicy(PCMMGlobalConfig.BETransmissionPolicy);
-            ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
-                    .setMaximumSustainedTrafficRate(PCMMGlobalConfig.DefaultLowBestEffortTrafficRate);
-            // PCMMGlobalConfig.DefaultBestEffortTrafficRate);
-
-            ((BestEffortService) trafficProfile).getReservedEnvelop()
-                    .setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
-            ((BestEffortService) trafficProfile).getReservedEnvelop()
-                    .setMaximumTrafficBurst(BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
-            ((BestEffortService) trafficProfile).getReservedEnvelop()
-                    .setRequestTransmissionPolicy(PCMMGlobalConfig.BETransmissionPolicy);
-            ((BestEffortService) trafficProfile).getReservedEnvelop()
-                    .setMaximumSustainedTrafficRate(PCMMGlobalConfig.DefaultLowBestEffortTrafficRate);
-            // PCMMGlobalConfig.DefaultBestEffortTrafficRate);
-
-            ((BestEffortService) trafficProfile).getCommittedEnvelop()
-                    .setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
-            ((BestEffortService) trafficProfile).getCommittedEnvelop()
-                    .setMaximumTrafficBurst(BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
-            ((BestEffortService) trafficProfile).getCommittedEnvelop()
-                    .setRequestTransmissionPolicy(PCMMGlobalConfig.BETransmissionPolicy);
-            ((BestEffortService) trafficProfile).getCommittedEnvelop()
-                    .setMaximumSustainedTrafficRate(PCMMGlobalConfig.DefaultLowBestEffortTrafficRate);
-            return trafficProfile;
-        }
-
-        @Override
-        public short getClassifierId() {
-            return classifierID;
-        }
-
-        @Override
-        public short getTransactionId() {
-            return transactionID;
-        }
-
-        @Override
-        public int getGateId() {
-            return gateID;
-        }
-    }
-
-}
diff --git a/packetcable-driver/src/test/java/org/pcmm/test/PCMMWorkflowTest.java b/packetcable-driver/src/test/java/org/pcmm/test/PCMMWorkflowTest.java
deleted file mode 100644 (file)
index 2485815..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-package org.pcmm.test;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.pcmm.rcd.ICMTS;
-import org.pcmm.rcd.IPCMMPolicyServer;
-import org.pcmm.rcd.IPCMMPolicyServer.IPSCMTSClient;
-import org.pcmm.rcd.impl.CMTS;
-import org.pcmm.rcd.impl.PCMMPolicyServer;
-
-public class PCMMWorkflowTest {
-
-       /**
-        * CMTS emulator, when testing with a real CMTS this should be set to null
-        * and shoudln't be started
-        */
-       private static ICMTS cmts;
-       /**
-        * CMTS host address, when testing with a real CMTS this should be CMTS
-        * address
-        */
-       private static InetAddress host;
-
-       private static IPCMMPolicyServer server;
-       private static IPSCMTSClient client;
-       private static boolean real_cmts = false;
-
-       @BeforeClass
-       public static void setUpBeforeClass() throws Exception {
-               if (real_cmts == true) {
-                    cmts = null;
-               } else {
-                    cmts = new CMTS();
-                    cmts.startServer();
-               }
-
-               server = new PCMMPolicyServer();
-               try {
-                       if (real_cmts == true) {
-                            // this should be set to the cmts host ex :
-                            // host = InetAddress.getByName(PCMMGlobalConfig.DefaultCMTS);
-                            host = InetAddress.getByName("10.200.90.3");
-                            host = InetAddress.getByName("127.0.0.1");
-                            // InetAddress.getByName("my-cmts-host-name");
-                       } else {
-                            host = InetAddress.getLocalHost();
-                       }
-                       assertNotNull(host);
-
-               } catch (UnknownHostException uhe) {
-                       fail("could not get host address ");
-               }
-               setupConnection();
-       }
-
-       @AfterClass
-       public static void tearDownAfterClass() throws Exception {
-               tearDown();
-               if (cmts != null)
-                       cmts.stopServer();
-       }
-
-       public static void setupConnection() {
-               client = server.requestCMTSConnection(host);
-               assertNotNull(client);
-       }
-
-       public static void tearDown() throws Exception {
-               assertNotNull(client);
-               assertTrue("Client disconnection failed", client.disconnect());
-       }
-
-       
-       //@Test
-       public void testGateSet() {
-               assertNotNull(client);
-               assertTrue("Gate-Set failed", client.gateSet());
-       }
-
-       //@Test
-       public void testGateDelete() {
-               assertNotNull(client);
-               assertTrue("Gate-Delete failed", client.gateDelete());
-
-       }
-
-       //@Test
-       public void testGateInfo() {
-               assertNotNull(client);
-               assertTrue("Gate-Info failed", client.gateInfo());
-       }
-
-       //@Test
-       public void testGateSynchronize() {
-               assertNotNull(client);
-               assertTrue("Gate-Synchronize failed", client.gateSynchronize());
-       }
-
-}