Example #1
0
  @Override
  public void storeSink(McastRoute route, ConnectPoint sink, Type operation) {
    MulticastData data =
        mcastRoutes.compute(
            route,
            (k, v) -> {
              switch (operation) {
                case ADD:
                  if (v == null) {
                    v = MulticastData.empty();
                  }
                  v.appendSink(sink);
                  break;
                case REMOVE:
                  if (v != null) {
                    v.removeSink(sink);
                  }
                  break;
                default:
                  log.warn("Unknown mcast operation type: {}", operation);
              }
              return v;
            });

    if (data != null) {
      switch (operation) {
        case ADD:
          delegate.notify(
              new McastEvent(
                  McastEvent.Type.SINK_ADDED,
                  McastRouteInfo.mcastRouteInfo(route, sink, data.source())));
          break;
        case REMOVE:
          if (data != null) {
            delegate.notify(
                new McastEvent(
                    McastEvent.Type.SINK_REMOVED,
                    McastRouteInfo.mcastRouteInfo(route, sink, data.source())));
          }
          break;
        default:
          log.warn("Unknown mcast operation type: {}", operation);
      }
    }
  }
Example #2
0
  @Override
  public void storeSource(McastRoute route, ConnectPoint source) {
    MulticastData data =
        mcastRoutes.compute(
            route,
            (k, v) -> {
              if (v == null) {
                return new MulticastData(source);
              } else {
                v.setSource(source);
              }
              return v;
            });

    if (data != null) {
      delegate.notify(
          new McastEvent(
              McastEvent.Type.SOURCE_ADDED,
              McastRouteInfo.mcastRouteInfo(route, data.sinks(), source)));
    }
  }
Example #3
0
 @Override
 public void storeRoute(McastRoute route, Type operation) {
   switch (operation) {
     case ADD:
       if (mcastRoutes.putIfAbsent(route, MulticastData.empty()) == null) {
         delegate.notify(
             new McastEvent(McastEvent.Type.ROUTE_ADDED, McastRouteInfo.mcastRouteInfo(route)));
       }
       break;
     case REMOVE:
       if (mcastRoutes.remove(route) != null) {
         delegate.notify(
             new McastEvent(McastEvent.Type.ROUTE_REMOVED, McastRouteInfo.mcastRouteInfo(route)));
       }
       break;
     default:
       log.warn("Unknown mcast operation type: {}", operation);
   }
 }
Example #4
0
 @Override
 public Set<ConnectPoint> sinksFor(McastRoute route) {
   return mcastRoutes.getOrDefault(route, MulticastData.empty()).sinks();
 }
Example #5
0
 @Override
 public ConnectPoint sourceFor(McastRoute route) {
   return mcastRoutes.getOrDefault(route, MulticastData.empty()).source();
 }