コード例 #1
0
 @Override
 public boolean updateBroadcastCache(Long entry, Short port) {
   if (timedCache.update(entry)) {
     AtomicLong count = portBroadcastCacheHitMap.get(port);
     if (count == null) {
       AtomicLong newCount = new AtomicLong(0);
       AtomicLong retrieved;
       if ((retrieved = portBroadcastCacheHitMap.putIfAbsent(port, newCount)) == null) {
         count = newCount;
       } else {
         count = retrieved;
       }
     }
     count.incrementAndGet();
     return true;
   } else {
     return false;
   }
 }
コード例 #2
0
  protected boolean isInBroadcastCache(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {
    // Get the cluster id of the switch.
    // Get the hash of the Ethernet packet.
    if (sw == null) return true;

    // If the feature is disabled, always return false;
    if (!broadcastCacheFeature) return false;

    Ethernet eth =
        IFloodlightProviderService.bcStore.get(cntx, IFloodlightProviderService.CONTEXT_PI_PAYLOAD);

    Long broadcastHash;
    broadcastHash =
        topology.getL2DomainId(sw.getId()) * prime1 + pi.getInPort() * prime2 + eth.hashCode();
    if (broadcastCache.update(broadcastHash)) {
      sw.updateBroadcastCache(broadcastHash, pi.getInPort());
      return true;
    } else {
      return false;
    }
  }