Ejemplo n.º 1
0
 @Override
 public synchronized void onSessionUp(final PccSession session) {
   // first session - delegate all PCC's LSPs
   // only when reporting at startup
   if (!this.sessions.containsKey(session.getId()) && session.getId() == 0) {
     for (final PlspId plspId : this.tunnels.keySet()) {
       setDelegation(plspId, session);
     }
   }
   this.sessions.put(session.getId(), session);
   if (!this.tunnels.isEmpty()) {
     // report all known LSPs
     for (final Entry<PlspId, Tunnel> entry : this.tunnels.entrySet()) {
       final Tunnel tunnel = entry.getValue();
       final boolean delegation = hasDelegation(tunnel, session);
       if (delegation) {
         tunnel.cancelTimeouts();
       }
       final long plspId = entry.getKey().getValue();
       final Tlvs tlvs =
           MsgBuilderUtil.createLspTlvs(
               plspId,
               true,
               getDestinationAddress(tunnel.getLspState().getEro().getSubobject(), this.address),
               this.address,
               this.address,
               Optional.of(tunnel.getPathName()));
       session.sendReport(
           createPcRtpMessage(
               createLsp(plspId, true, Optional.<Tlvs>fromNullable(tlvs), delegation, false),
               NO_SRP,
               tunnel.getLspState()));
     }
     // end-of-sync marker
     session.sendReport(
         createPcRtpMessage(
             createLsp(0, false, Optional.<Tlvs>absent(), true, false),
             NO_SRP,
             createPath(Collections.<Subobject>emptyList())));
   }
 }