2 * Copyright (c) 2015 Cable Television Laboratories, Inc. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.pcmm.rcd.impl;
11 import org.pcmm.gates.IGateSpec.Direction;
12 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory;
14 import org.umu.cops.prpep.COPSPepConnection;
15 import org.umu.cops.prpep.COPSPepDataProcess;
16 import org.umu.cops.prpep.COPSPepException;
17 import org.umu.cops.prpep.COPSPepReqStateMan;
18 import org.umu.cops.stack.COPSException;
19 import org.umu.cops.stack.COPSHandle;
21 import java.net.Socket;
22 import java.util.Collections;
27 * The connection object for the PCMM CMTS
29 class PcmmCmtsConnection extends COPSPepConnection {
31 private final static Logger logger = LoggerFactory.getLogger(COPSPepConnection.class);
34 * The configured gates
36 private final Map<Direction, Set<String>> gateConfig;
39 * The connected CMTSs and whether or not they are up
41 private final Map<String, Boolean> cmStatus;
45 * @param clientType - the client-type
46 * @param sock - the socket connection
47 * @param gateConfig - the configured gates
48 * @param cmStatus - the configured CMs and whether or each is connected
50 public PcmmCmtsConnection(final short clientType, final Socket sock, final Map<Direction, Set<String>> gateConfig,
51 final Map<String, Boolean> cmStatus) {
52 super(clientType, sock);
53 this.gateConfig = Collections.unmodifiableMap(gateConfig);
54 this.cmStatus = Collections.unmodifiableMap(cmStatus);
58 public COPSPepReqStateMan addRequestState(final COPSHandle clientHandle, final COPSPepDataProcess process)
59 throws COPSException {
60 final COPSPepReqStateMan manager = new CmtsPepReqStateMan(_clientType, clientHandle, (CmtsDataProcessor)process,
61 _sock, gateConfig, cmStatus);
62 if (_managerMap.get(clientHandle) != null)
63 throw new COPSPepException("Duplicate Handle, rejecting " + clientHandle);
65 _managerMap.put(clientHandle, manager);
66 logger.info("Added state manager with key - " + clientHandle);
67 manager.initRequestState();