Java Collections.synchronizedSet Examples

Java Collections.synchronizedSet - 30 examples found. These are the top rated real world Java examples of java.util.Collections.synchronizedSet extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
  public ModuleManager(Receptor rec) {
    mlce = new ModuleListChangedEvent(rec);
    mae = new ModuleAddedEvent(rec);
    mre = new ModuleRemovedEvent(rec);

    recOut = rec.getOutComm();
    dbReportListeners = new LinkedList();
    listeners = new LinkedList();
    receptor = rec;
    modToHandle = new HashMap();
    hashToModule = new HashMap();
    handleToAnalMod = new HashMap();
    handles = new LinkedList();
    nameToFInst = new HashMap();

    downloadSet = Collections.synchronizedSet(new HashSet());
    checkingSet = Collections.synchronizedSet(new HashSet());
    phantomModules = Collections.synchronizedList(new LinkedList());

    ModuleLinker linker = receptor.getLinker();
    Iterator it = linker.getDescriptors().iterator();
    while (it.hasNext()) {
      ModuleDescriptor desc = (ModuleDescriptor) it.next();
      if (desc.getType() == Descriptor.TYPE_FLOW) {
        loadFlowModule(desc);
      }
    }

    refresh = Settings.v().getRefreshInterval();
    Settings.v().addConfigChangeListener(this);
    receptor.getLinker().addModuleLinkerListener(this);

    (refThread = new Thread(this, "Module Manager")).start();
  }
 /**
  * During recovery we need to duplicate service info to reregister them
  *
  * @param info
  */
 ServiceInfoImpl(ServiceInfo info) {
   this._ipv4Addresses = Collections.synchronizedSet(new LinkedHashSet<Inet4Address>());
   this._ipv6Addresses = Collections.synchronizedSet(new LinkedHashSet<Inet6Address>());
   if (info != null) {
     this._domain = info.getDomain();
     this._protocol = info.getProtocol();
     this._application = info.getApplication();
     this._name = info.getName();
     this._subtype = info.getSubtype();
     this._port = info.getPort();
     this._weight = info.getWeight();
     this._priority = info.getPriority();
     this._text = info.getTextBytes();
     this._persistent = info.isPersistent();
     Inet6Address[] ipv6Addresses = info.getInet6Addresses();
     for (Inet6Address address : ipv6Addresses) {
       this._ipv6Addresses.add(address);
     }
     Inet4Address[] ipv4Addresses = info.getInet4Addresses();
     for (Inet4Address address : ipv4Addresses) {
       this._ipv4Addresses.add(address);
     }
   }
   this._state = new ServiceInfoState(this);
 }
Example #3
0
  public FManager() {

    loaded =
        Collections.synchronizedSet(
            new HashSet<File>() {
              @Override
              public boolean add(File e) {
                synchronized (loadedObserver) {
                  loadedObserver.setChanged();
                  loadedObserver.notifyObservers(e);
                }
                return super.add(e);
              }
            });
    pending = Collections.synchronizedSet(new HashSet<>());
    filterChange = new InvokeObservable(this);
    loadedObserver = new InvokeObservable(this);
    activityObserver = new InvokeObservable(this);
    autoLoad = true;
    verbose = true;
    activity = IDLE;
    stdErr = Optional.empty();
    stdOut = Optional.empty();
    FPC fpcObject = null;
    try {
      fpcObject = new FPC(DataDetails.class);
      fpcObject.onFilterChange(this::setActiveFilter);
    } catch (Exception ex) {
      Logger.getLogger(FManager.class.getName()).log(Level.SEVERE, null, ex);
    }
    fpc = fpcObject;
    checkProperties();
  }
  ServiceInfoImpl(
      Map<Fields, String> qualifiedNameMap,
      int port,
      int weight,
      int priority,
      boolean persistent,
      byte text[]) {
    Map<Fields, String> map = ServiceInfoImpl.checkQualifiedNameMap(qualifiedNameMap);

    this._domain = map.get(Fields.Domain);
    this._protocol = map.get(Fields.Protocol);
    this._application = map.get(Fields.Application);
    this._name = map.get(Fields.Instance);
    this._subtype = map.get(Fields.Subtype);

    this._port = port;
    this._weight = weight;
    this._priority = priority;
    this._text = text;
    this.setNeedTextAnnouncing(false);
    this._state = new ServiceInfoState(this);
    this._persistent = persistent;
    this._ipv4Addresses = Collections.synchronizedSet(new LinkedHashSet<Inet4Address>());
    this._ipv6Addresses = Collections.synchronizedSet(new LinkedHashSet<Inet6Address>());
  }
 Set<String> getInEdgesSet(final String label) {
   Set<String> edgeIds = getInEdgesMap().get(label);
   if (edgeIds == null) {
     Object o = getProperty(DominoVertex.IN_PREFIX + label, java.util.Collection.class);
     if (o != null) {
       if (o instanceof LinkedHashSet) {
         edgeIds = Collections.synchronizedSet((LinkedHashSet) o);
       } else if (o instanceof java.util.Collection) {
         edgeIds = Collections.synchronizedSet(new LinkedHashSet<String>((Collection<String>) o));
       } else {
         log_.log(
             Level.WARNING,
             "ALERT! InEdges for label "
                 + label
                 + " returned something other than a Collection "
                 + o.getClass().getName()
                 + " in vertex type "
                 + this.getForm()
                 + " id: "
                 + getId());
       }
     } else {
       edgeIds = Collections.synchronizedSet(new LinkedHashSet<String>());
     }
     Map map = getInEdgesMap();
     synchronized (map) {
       map.put(label, edgeIds);
     }
   }
   return edgeIds;
 }
  protected Set<Edge> getOutEdgeObjects(final String... labels) {
    Map<String, Set<Edge>> outCache = getOutEdgeCache();
    Set<Edge> result = null;

    if (labels == null || labels.length == 0) {
      result = new LinkedHashSet<Edge>();
      Set<String> labelSet = this.getOutEdgeLabels();
      //			System.out.println("INFO: Getting all OUT edges for a vertex across " + labelSet.size() +
      // " labels.");
      for (String label : labelSet) {
        Set<Edge> curEdges = getOutEdgeObjects(label);
        //				System.out.println("INFO: Found " + curEdges.size() + " OUT edges for label " +
        // label);
        result.addAll(curEdges);
      }
      //			System.out.println("INFO: Found " + result.size() + " OUT edges.");
    } else if (labels.length == 1) {
      String label = labels[0];
      if (label == null) {
        return Collections.unmodifiableSet(getOutEdgeObjects());
      }
      synchronized (outCache) {
        result = outCache.get(label);
      }
      if (result == null) {
        Set<String> edgeIds = getOutEdgesSet(label);
        Set<Edge> edges = getParent().getEdgesFromIds(edgeIds);
        if (edges != null) {
          result = Collections.synchronizedSet((LinkedHashSet) edges);
        }

        // result = Collections.synchronizedSet(new LinkedHashSet<Edge>());
        // Set<Edge> allEdges = Collections.unmodifiableSet(getOutEdgeObjects());
        // if (!allEdges.isEmpty()) {
        // for (Edge edge : allEdges) {
        // if (edge == null) {
        //
        // } else {
        // String curLabel = edge.getLabel();
        // if (label.equals(curLabel)) {
        // result.add(edge);
        // }
        // }
        // }
        // }

        synchronized (outCache) {
          outCache.put(label, result);
        }
      }
    } else {
      result = Collections.synchronizedSet(new LinkedHashSet<Edge>());
      for (String label : labels) {
        result.addAll(getOutEdgeObjects(label));
      }
    }
    return Collections.unmodifiableSet(result);
  }