*/
package org.opendaylight.protocol.pcep.testtool;
+import io.netty.util.HashedWheelTimer;
import io.netty.util.concurrent.GlobalEventExecutor;
-import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.List;
import org.opendaylight.protocol.framework.DispatcherImpl;
import org.opendaylight.protocol.framework.NeverReconnectStrategy;
-import org.opendaylight.protocol.framework.SessionPreferences;
-import org.opendaylight.protocol.pcep.PCEPConnection;
+import org.opendaylight.protocol.pcep.PCEPMessage;
+import org.opendaylight.protocol.pcep.PCEPSession;
import org.opendaylight.protocol.pcep.PCEPSessionListener;
-import org.opendaylight.protocol.pcep.PCEPSessionPreferences;
-import org.opendaylight.protocol.pcep.PCEPSessionProposal;
-import org.opendaylight.protocol.pcep.PCEPSessionProposalChecker;
-import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
+import org.opendaylight.protocol.pcep.PCEPTerminationReason;
import org.opendaylight.protocol.pcep.PCEPTlv;
+import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
import org.opendaylight.protocol.pcep.impl.PCEPDispatcherImpl;
-import org.opendaylight.protocol.pcep.impl.PCEPMessageFactory;
import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
import org.opendaylight.protocol.pcep.tlv.NodeIdentifierTlv;
public class PCCMock {
- public static void main(final String[] args) throws IOException, InterruptedException {
+ public static void main(final String[] args) throws Exception {
final List<PCEPTlv> tlvs = Lists.newArrayList();
tlvs.add(new NodeIdentifierTlv(new byte[] { (byte) 127, (byte) 2, (byte) 3, (byte) 7 }));
- final PCEPSessionPreferences prop = new PCEPSessionPreferences(new PCEPOpenObject(30, 120, 0, tlvs));
- final DispatcherImpl di = new DispatcherImpl(new PCEPMessageFactory());
- final PCEPDispatcherImpl d = new PCEPDispatcherImpl(di, new PCEPSessionProposalFactory() {
-
- @Override
- public PCEPSessionProposal getSessionProposal(final InetSocketAddress address, final int sessionId) {
- return new PCEPSessionProposal() {
-
- @Override
- public PCEPSessionPreferences getProposal() {
- return prop;
- }
- };
- }
- });
+
+ final DispatcherImpl di = new DispatcherImpl();
+ final PCEPDispatcherImpl d = new PCEPDispatcherImpl(di,
+ new DefaultPCEPSessionNegotiatorFactory(new HashedWheelTimer(), new PCEPOpenObject(30, 120, 0, tlvs), 0));
try {
+ d.createClient(new InetSocketAddress("127.0.0.3", 12345),
+ new PCEPSessionListener() {
- final PCEPSessionProposalChecker check = new PCEPSessionProposalChecker() {
@Override
- public Boolean checkSessionCharacteristics(final SessionPreferences openObj) {
- return true;
- }
+ public void onMessage(final PCEPSession session, final PCEPMessage message) {
+ // TODO Auto-generated method stub
- @Override
- public PCEPSessionPreferences getNewProposal(final SessionPreferences open) {
- return new PCEPSessionPreferences(new PCEPOpenObject(30, 120, 0, null));
}
- };
- d.createClient(new PCEPConnection() {
@Override
- public InetSocketAddress getPeerAddress() {
- return new InetSocketAddress("127.0.0.3", 12345);
- }
+ public void onSessionUp(final PCEPSession session) {
+ // TODO Auto-generated method stub
- @Override
- public PCEPSessionProposalChecker getProposalChecker() {
- return check;
}
@Override
- public PCEPSessionPreferences getProposal() {
- return prop;
+ public void onSessionDown(final PCEPSession session, final Exception e) {
+ // TODO Auto-generated method stub
+
}
@Override
- public PCEPSessionListener getListener() {
- return new SimpleSessionListener();
+ public void onSessionTerminated(final PCEPSession session,
+ final PCEPTerminationReason cause) {
+ // TODO Auto-generated method stub
+
}
- }, new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 2000));
+ }, new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 2000)).get();
+
// Thread.sleep(5000);
// final List<CompositeRequestObject> cro = new ArrayList<CompositeRequestObject>();
// cro.add(new CompositeRequestObject(new PCEPRequestParameterObject(false, true, true, true, true, (short)
// }
// Thread.sleep(5000);
// Thread.sleep(1000);
-
} finally {
// di.stop();
}