コード例 #1
6
  protected void logoutAllSessions(boolean forceDisconnect) {
    log.info("Logging out all sessions");
    if (sessions == null) {
      log.error("Attempt to logout all sessions before initialization is complete.");
      return;
    }
    for (Session session : sessions.values()) {
      try {
        session.logout();
      } catch (Throwable e) {
        logError(session.getSessionID(), null, "Error during logout", e);
      }
    }

    if (forceDisconnect && isLoggedOn()) {
      for (Session session : sessions.values()) {
        try {
          if (session.isLoggedOn()) {
            session.disconnect("Forcibly disconnecting session", false);
          }
        } catch (Throwable e) {
          logError(session.getSessionID(), null, "Error during disconnect", e);
        }
      }
    }

    if (!forceDisconnect) {
      waitForLogout();
    }
  }
コード例 #2
0
ファイル: PlayerManager.java プロジェクト: electrozzLOL/Jobs
  /** Save all the information of all of the players in the game */
  public void saveAll() {
    JobsDAO dao = plugin.getJobsCore().getJobsDAO();

    /*
     * Saving is a three step process to minimize synchronization locks when called asynchronously.
     *
     * 1) Safely copy list for saving.
     * 2) Perform save on all players on copied list.
     * 3) Garbage collect the real list to remove any offline players with saved data
     */
    ArrayList<JobsPlayer> list = null;
    synchronized (players) {
      list = new ArrayList<JobsPlayer>(players.values());
    }

    for (JobsPlayer jPlayer : list) {
      jPlayer.save(dao);
    }

    synchronized (players) {
      Iterator<JobsPlayer> iter = players.values().iterator();
      while (iter.hasNext()) {
        JobsPlayer jPlayer = iter.next();
        synchronized (jPlayer.saveLock) {
          if (!jPlayer.isOnline() && jPlayer.isSaved()) {
            iter.remove();
          }
        }
      }
    }
  }
コード例 #3
0
ファイル: ClusterManagerImpl.java プロジェクト: alesj/hornetq
  public synchronized void start() throws Exception {
    if (started) {
      return;
    }

    for (BroadcastGroup group : broadcastGroups.values()) {
      if (!backup) {
        group.start();
      }
    }

    for (ClusterConnection conn : clusterConnections.values()) {
      conn.start();
      if (backup && configuration.isSharedStore()) {
        conn.informTopology();
        conn.announceBackup();
      }
    }

    for (BridgeConfiguration config : configuration.getBridgeConfigurations()) {
      deployBridge(config, !backup);
    }

    started = true;
  }
コード例 #4
0
ファイル: ResourceManager.java プロジェクト: NCDuster/shr5rcp
 /** Dispose all of the cached images. */
 public static void disposeImages() {
   SWTResourceManager.disposeImages();
   // dispose ImageDescriptor images
   {
     for (Iterator<Image> I = m_descriptorImageMap.values().iterator(); I.hasNext(); ) {
       I.next().dispose();
     }
     m_descriptorImageMap.clear();
   }
   // dispose decorated images
   for (int i = 0; i < m_decoratedImageMap.length; i++) {
     Map<Image, Map<Image, Image>> cornerDecoratedImageMap = m_decoratedImageMap[i];
     if (cornerDecoratedImageMap != null) {
       for (Map<Image, Image> decoratedMap : cornerDecoratedImageMap.values()) {
         for (Image image : decoratedMap.values()) {
           image.dispose();
         }
         decoratedMap.clear();
       }
       cornerDecoratedImageMap.clear();
     }
   }
   // dispose plugin images
   {
     for (Iterator<Image> I = m_URLImageMap.values().iterator(); I.hasNext(); ) {
       I.next().dispose();
     }
     m_URLImageMap.clear();
   }
 }
コード例 #5
0
 @Override
 public List<PermissionGroupInfo> getAllPermissionGroups(int flags) throws RemoteException {
   waitForReadyInner();
   try {
     enforcePluginFileExists();
     List<PermissionGroupInfo> list = new ArrayList<PermissionGroupInfo>();
     if (shouldNotBlockOtherInfo()) {
       for (PluginPackageParser pluginPackageParser : mPluginCache.values()) {
         List<PermissionGroupInfo> permissionGroupInfos =
             pluginPackageParser.getPermissionGroups();
         for (PermissionGroupInfo permissionGroupInfo : permissionGroupInfos) {
           if (!list.contains(permissionGroupInfo)) {
             list.add(permissionGroupInfo);
           }
         }
       }
     } else {
       List<String> pkgs = mActivityManagerService.getPackageNamesByPid(Binder.getCallingPid());
       for (PluginPackageParser pluginPackageParser : mPluginCache.values()) {
         List<PermissionGroupInfo> permissionGroupInfos =
             pluginPackageParser.getPermissionGroups();
         for (PermissionGroupInfo permissionGroupInfo : permissionGroupInfos) {
           if (!list.contains(permissionGroupInfo)
               && pkgs.contains(permissionGroupInfo.packageName)) {
             list.add(permissionGroupInfo);
           }
         }
       }
     }
     return list;
   } catch (Exception e) {
     handleException(e);
   }
   return null;
 }
コード例 #6
0
ファイル: TestMap.java プロジェクト: jtransc/jtransc
  public void testFailFastValues() {
    if (!isAddRemoveModifiable()) {
      return;
    }
    if (!isFailFastExpected()) {
      return;
    }
    resetFull();
    Iterator it = map.values().iterator();
    it.next();
    map.remove(map.keySet().iterator().next());
    try {
      it.next();
      fail();
    } catch (ConcurrentModificationException expected) {
    }

    resetFull();
    it = map.values().iterator();
    it.next();
    map.clear();
    try {
      it.next();
      fail();
    } catch (ConcurrentModificationException expected) {
    }
  }
コード例 #7
0
    public void secondPhase() {
      int count = _ways.values().size();

      // This copies relevant tags to the ways (highway=*) where it doesn't exist, so that
      // the way purging keeps the needed way around.
      // Multipolygons may be processed more than once, which may be needed since
      // some member might be in different files for the same multipolygon.
      processMultipolygons();

      for (Iterator<OSMWay> it = _ways.values().iterator(); it.hasNext(); ) {
        OSMWay way = it.next();
        if (!(way.hasTag("highway") || way.isTag("railway", "platform"))) {
          it.remove();
        } else if (way.isTag("highway", "conveyer") || way.isTag("highway", "proposed")) {
          it.remove();
        } else {
          // Since the way is kept, update nodes-with-neighbors
          List<Long> nodes = way.getNodeRefs();
          if (nodes.size() > 1) {
            _nodesWithNeighbors.addAll(nodes);
          }
        }
      }

      _log.trace("purged " + (count - _ways.values().size()) + " ways out of " + count);
    }
コード例 #8
0
 private void checkAccessors(
     @NotNull JetProperty property, @NotNull PropertyDescriptor propertyDescriptor) {
   for (JetPropertyAccessor accessor : property.getAccessors()) {
     PropertyAccessorDescriptor propertyAccessorDescriptor =
         accessor.isGetter() ? propertyDescriptor.getGetter() : propertyDescriptor.getSetter();
     assert propertyAccessorDescriptor != null
         : "No property accessor descriptor for " + property.getText();
     modifiersChecker.checkModifiersForDeclaration(accessor, propertyAccessorDescriptor);
     modifiersChecker.reportIllegalModalityModifiers(accessor);
   }
   JetPropertyAccessor getter = property.getGetter();
   PropertyGetterDescriptor getterDescriptor = propertyDescriptor.getGetter();
   JetModifierList getterModifierList = getter != null ? getter.getModifierList() : null;
   if (getterModifierList != null && getterDescriptor != null) {
     Map<JetModifierKeywordToken, ASTNode> nodes =
         ModifiersChecker.getNodesCorrespondingToModifiers(
             getterModifierList,
             Sets.newHashSet(
                 JetTokens.PUBLIC_KEYWORD,
                 JetTokens.PROTECTED_KEYWORD,
                 JetTokens.PRIVATE_KEYWORD,
                 JetTokens.INTERNAL_KEYWORD));
     if (getterDescriptor.getVisibility() != propertyDescriptor.getVisibility()) {
       for (ASTNode node : nodes.values()) {
         trace.report(Errors.GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY.on(node.getPsi()));
       }
     } else {
       for (ASTNode node : nodes.values()) {
         trace.report(Errors.REDUNDANT_MODIFIER_IN_GETTER.on(node.getPsi()));
       }
     }
   }
 }
コード例 #9
0
ファイル: XMLSchema.java プロジェクト: wilden/deegree2-base
 @Override
 public String toString() {
   StringBuffer sb = new StringBuffer("XML Schema targetNamespace='");
   sb.append(targetNamespace);
   sb.append("'\n");
   sb.append("\n*** ");
   sb.append(elementMap.size());
   sb.append(" global element declarations ***\n");
   for (ElementDeclaration elemDec : elementMap.values()) {
     sb.append(elemDec.toString(""));
   }
   sb.append("\n*** ");
   sb.append(simpleTypeMap.size());
   sb.append(" global simple type declarations ***\n");
   for (SimpleTypeDeclaration type : simpleTypeMap.values()) {
     sb.append(type.toString(""));
   }
   sb.append("\n*** ");
   sb.append(complexTypeMap.size());
   sb.append(" global complex type declarations ***\n");
   for (ComplexTypeDeclaration type : complexTypeMap.values()) {
     sb.append(type.toString(""));
   }
   return sb.toString();
 }
コード例 #10
0
ファイル: BoardLine.java プロジェクト: vitormota/MFES_SHOGI
 // ***** VDMTOOLS START Name=inv_BoardLine KEEP=NO
 public Boolean inv_BoardLine() {
   Boolean rexpr_2 = null;
   Set var2_5 = new HashSet();
   var2_5 = new HashSet();
   for (int count_8 = 1; count_8 <= 9; count_8++) var2_5.add(new Integer(count_8));
   if ((rexpr_2 = Boolean.valueOf(UTIL.Contains(var2_5, y))).booleanValue()) {
     Boolean var2_11 = null;
     Boolean var1_12 = null;
     if ((var1_12 = Boolean.valueOf(new HashSet(line.keySet()).size() == 9)).booleanValue()) {
       Set var2_21 = new HashSet();
       var2_21 = new HashSet();
       for (int count_24 = 1; count_24 <= 9; count_24++) var2_21.add(new Integer(count_24));
       var1_12 = Boolean.valueOf(UTIL.equals(new HashSet(line.keySet()), var2_21));
     }
     if ((var2_11 = var1_12).booleanValue()) {
       Boolean var2_27 = null;
       boolean tmpQuant_29 = true;
       {
         Set e1_set_32 = new HashSet(line.values());
         Cell c = null;
         Set tmpSet_40 = new HashSet(e1_set_32);
         for (Iterator enm_39 = tmpSet_40.iterator(); enm_39.hasNext() && tmpQuant_29; ) {
           Cell elem_38 = (Cell) enm_39.next();
           /* c */
           c = elem_38;
           if (!((c.y).intValue() == y.intValue())) tmpQuant_29 = false;
         }
       }
       if ((var2_27 = Boolean.valueOf(tmpQuant_29)).booleanValue()) {
         boolean tmpQuant_43 = false;
         {
           Set e1_set_46 = new HashSet(line.values());
           Cell c1 = null;
           Cell c2 = null;
           Set e_set_60 = e1_set_46;
           Set tmpSet_63 = new HashSet(e_set_60);
           for (Iterator enm_62 = tmpSet_63.iterator(); enm_62.hasNext() && !tmpQuant_43; ) {
             Cell elem_61 = (Cell) enm_62.next();
             /* c2 */
             c2 = elem_61;
             Set tmpSet_59 = new HashSet(e1_set_46);
             for (Iterator enm_58 = tmpSet_59.iterator(); enm_58.hasNext() && !tmpQuant_43; ) {
               Cell elem_57 = (Cell) enm_58.next();
               /* c1 */
               c1 = elem_57;
               Boolean pred_47 = null;
               if ((pred_47 = Boolean.valueOf(!UTIL.equals(c1, c2))).booleanValue())
                 pred_47 = Boolean.valueOf((c1.x).intValue() == (c2.x).intValue());
               if (pred_47.booleanValue()) tmpQuant_43 = true;
             }
           }
         }
         var2_27 = Boolean.valueOf(!tmpQuant_43);
       }
       var2_11 = var2_27;
     }
     rexpr_2 = var2_11;
   }
   return rexpr_2;
 }
コード例 #11
0
  public void testRetries() {
    JUnitMessageQueue queue = createQueue(TWO_CLIENTS, ONE_BLOCK, ONE_TEST_PER_BLOCK);
    TestInfo testInfo = queue.getTestBlocks().get(0)[0];
    Map<TestInfo, JUnitResult> results = new HashMap<TestInfo, JUnitResult>();
    JUnitResult junitResult = new JUnitResult();
    junitResult.setException(new AssertionError());
    results.put(testInfo, junitResult);
    queue.reportResults(createClientInfo(0, "ff3"), results);
    assertTrue(queue.needsRerunning(testInfo));
    Map<ClientStatus, JUnitResult> queueResults = queue.getResults(testInfo);
    assertEquals(1, queueResults.size());
    for (JUnitResult result : queueResults.values()) {
      assertNotNull(result.getException());
    }

    queue.removeResults(testInfo);

    queue.reportResults(createClientInfo(0, "ff3"), createTestResults(ONE_TEST_PER_BLOCK));
    queue.reportResults(createClientInfo(1, "ie6"), createTestResults(ONE_TEST_PER_BLOCK));
    assertFalse(queue.needsRerunning(testInfo));
    // check that the updated result appears now.
    queueResults = queue.getResults(testInfo);
    assertEquals(2, queueResults.size());
    for (JUnitResult result : queueResults.values()) {
      assertNull(result.getException());
    }
  }
コード例 #12
0
  private FigureMovableImpl createFigure(InputStream is) throws Exception {
    FigureType figureType = unmarshall(is);

    Map<String, Vertex> vertices = new HashMap<String, Vertex>();
    for (VertexType vertexType : figureType.getVertices()) {
      vertices.put(vertexType.getName(), createVertexFrom(vertexType));
    }

    Map<String, Edge> edges = new HashMap<String, Edge>();
    Map<Vertex, Set<Edge>> verticesEdges = new HashMap<Vertex, Set<Edge>>();
    for (EdgeType edgeType : figureType.getEdges()) {
      Edge edge = createEdgeFrom(edgeType, vertices);

      putEdgeIntoVerticesEdgesMap(verticesEdges, edge.getA(), edge);
      putEdgeIntoVerticesEdgesMap(verticesEdges, edge.getB(), edge);
      edges.put(edgeType.getName(), edge);
    }

    Map<String, Face> faces = new HashMap<String, Face>();
    for (FaceType faceType : figureType.getFaces()) {
      faces.put(faceType.getName(), createFaceFrom(faceType, edges, vertices, verticesEdges));
    }

    Double givenPrecision = figureType.getPrecision();
    double precision = (givenPrecision != null) ? givenPrecision : Pointable.PRECISION;

    return new FigureMovableImpl(
        new HashSet<Face>(faces.values()), new HashSet<Edge>(edges.values()), precision);
  }
コード例 #13
0
ファイル: PageRank.java プロジェクト: RMathews/IR
  private static void process() {
    double nLinks = linkMap.size();
    int iteration = 1;
    do {
      double sinkPR = 0;

      double perplexity = getPerplexity(getEntropyAndResetRank());
      // System.out.println("Perplexity at iteration " + iteration + " = " + perplexity );

      for (Link sink : sinks) {
        sinkPR += sink.getOldPageRank();
      }
      for (Link link : linkMap.values()) {
        double newPageRank = (1 - DAMPING_FACTOR) / nLinks;
        newPageRank += DAMPING_FACTOR * sinkPR / nLinks;
        for (Link inLink : link.getInLinks()) {
          newPageRank += DAMPING_FACTOR * inLink.getOldPageRank() / inLink.getOutLinks().size();
        }
        link.setNewPageRank(newPageRank);
      }

      if (iteration == 1 || iteration == 10 || iteration == 100) {
        System.out.println("Iteration : " + iteration);
        System.out.println("Perplexity : " + perplexity);
        for (Link link : linkMap.values()) {
          System.out.println(link);
        }
      }
    } while (++iteration <= 100);
  }
コード例 #14
0
 private synchronized Address addAndUpdateAddressMap(final SimpleString address) {
   Address add = new AddressImpl(address);
   Address actualAddress;
   if (add.containsWildCard()) {
     actualAddress = wildCardAddresses.get(address);
   } else {
     actualAddress = addresses.get(address);
   }
   if (actualAddress == null) {
     actualAddress = add;
     addAddress(address, actualAddress);
   }
   if (actualAddress.containsWildCard()) {
     for (Address destAdd : addresses.values()) {
       if (destAdd.matches(actualAddress)) {
         destAdd.addLinkedAddress(actualAddress);
         actualAddress.addLinkedAddress(destAdd);
       }
     }
   } else {
     for (Address destAdd : wildCardAddresses.values()) {
       if (actualAddress.matches(destAdd)) {
         destAdd.addLinkedAddress(actualAddress);
         actualAddress.addLinkedAddress(destAdd);
       }
     }
   }
   return actualAddress;
 }
コード例 #15
0
ファイル: GroupManager.java プロジェクト: Eising/opennms
  /**
   * saveGroups
   *
   * @throws java.lang.Exception if any.
   */
  public synchronized void saveGroups() throws Exception {
    Header header = m_oldHeader;

    if (header != null) header.setCreated(EventConstants.formatToString(new Date()));

    Groups groups = new Groups();
    for (Group grp : m_groups.values()) {
      groups.addGroup(grp);
    }

    Roles roles = new Roles();
    for (Role role : m_roles.values()) {
      roles.addRole(role);
    }

    Groupinfo groupinfo = new Groupinfo();
    groupinfo.setGroups(groups);
    if (roles.getRoleCount() > 0) groupinfo.setRoles(roles);
    groupinfo.setHeader(header);

    m_oldHeader = header;

    // marshal to a string first, then write the string to the file. This
    // way the original configuration
    // isn't lost if the XML from the marshal is hosed.
    StringWriter stringWriter = new StringWriter();
    Marshaller.marshal(groupinfo, stringWriter);
    String data = stringWriter.toString();
    saveXml(data);
  }
コード例 #16
0
  public void checkLineMarkers(
      @NotNull Collection<LineMarkerInfo> markerInfos, @NotNull String text) {
    String fileName = myFile == null ? "" : myFile.getName() + ": ";
    String failMessage = "";

    for (LineMarkerInfo info : markerInfos) {
      if (!containsLineMarker(info, myLineMarkerInfos.values())) {
        if (!failMessage.isEmpty()) failMessage += '\n';
        failMessage +=
            fileName
                + "Extra line marker highlighted "
                + rangeString(text, info.startOffset, info.endOffset)
                + ": '"
                + info.getLineMarkerTooltip()
                + "'";
      }
    }

    for (LineMarkerInfo expectedLineMarker : myLineMarkerInfos.values()) {
      if (!markerInfos.isEmpty() && !containsLineMarker(expectedLineMarker, markerInfos)) {
        if (!failMessage.isEmpty()) failMessage += '\n';
        failMessage +=
            fileName
                + "Line marker was not highlighted "
                + rangeString(text, expectedLineMarker.startOffset, expectedLineMarker.endOffset)
                + ": '"
                + expectedLineMarker.getLineMarkerTooltip()
                + "'";
      }
    }

    if (!failMessage.isEmpty()) Assert.fail(failMessage);
  }
コード例 #17
0
ファイル: GroupManager.java プロジェクト: Eising/opennms
  /**
   * When this method is called group name is changed, so also is the group name belonging to the
   * view. Also overwrites the "groups.xml" file
   *
   * @param oldName a {@link java.lang.String} object.
   * @param newName a {@link java.lang.String} object.
   * @throws java.lang.Exception if any.
   */
  public synchronized void renameUser(String oldName, String newName) throws Exception {
    // Get the old data
    if (oldName == null || newName == null || oldName == "" || newName == "") {
      throw new Exception("Group Factory: Rename user.. no value ");
    } else {
      Map<String, Group> map = new LinkedHashMap<String, Group>();

      for (Group group : m_groups.values()) {
        for (ListIterator<String> userList = group.getUserCollection().listIterator();
            userList.hasNext(); ) {
          String name = userList.next();

          if (name.equals(oldName)) {
            userList.set(newName);
          }
        }
        map.put(group.getName(), group);
      }

      m_groups.clear();
      m_groups.putAll(map);

      for (Role role : m_roles.values()) {
        for (Schedule sched : role.getScheduleCollection()) {
          if (oldName.equals(sched.getName())) {
            sched.setName(newName);
          }
        }
      }

      saveGroups();
    }
  }
コード例 #18
0
  public void save(
      @NotNull SchemaFormContentAware newEntity,
      SchemaFormContentAware oldEntity,
      String entityPath) {
    Assert.notNull(newEntity, "New content cannot be null");

    Object json = defaultConfiguration().jsonProvider().parse(newEntity.getContent());
    DocumentContext newContext =
        JsonPath.using(defaultConfiguration().addOptions(Option.AS_PATH_LIST)).parse(json);
    Map<String, JSONArray> newPaths = getPathFilesMap(newContext, json);
    if (newPaths == null) return; // content does not have any file field

    if (oldEntity != null) {
      Object oldJson = defaultConfiguration().jsonProvider().parse(oldEntity.getContent());
      DocumentContext oldContext =
          JsonPath.using(defaultConfiguration().addOptions(Option.AS_PATH_LIST)).parse(oldJson);
      Map<String, JSONArray> oldPaths = getPathFilesMap(oldContext, oldJson);
      if (oldPaths != null) {
        saveAndDelete(oldPaths, newPaths, entityPath);
      } else {
        // schema and definition now have files
        newPaths.values().stream().forEach(v -> saveFiles(v, entityPath));
      }

    } else {
      newPaths.values().stream().forEach(v -> saveFiles(v, entityPath));
    }

    cleanup(newPaths, newContext);
    newEntity.setContent(newContext.jsonString());
  }
コード例 #19
0
ファイル: Renamer.java プロジェクト: MarkGore/ASM-Renamer
 // TODO: Pass renaming rules to this method.
 public Remapper rename(Map<String, LinkedInterfaceNode> tree) {
   for (LinkedInterfaceNode node : tree.values()) {
     boolean cont;
     do {
       cont = false;
       if (node.rename("Class" + classPostfix) && !node.external) {
         ++classPostfix;
         cont = true;
       }
     } while (cont);
   }
   NameRemapper remapper = new NameRemapper(tree);
   for (LinkedInterfaceNode node : tree.values()) {
     if (node.name.startsWith("jag") && node.name.startsWith("jac")) {
       continue;
     }
     if (!node.external) {
       for (MemberNode field : node.getFields()) {
         if (node.renameField(field, getFieldName(remapper, field.desc, fieldPostfix))) {
           ++fieldPostfix;
         }
       }
       for (MemberNode method : node.getMethods()) {
         if (method.name.length() < 3) {
           if (node.renameMethod(method, "method" + methodPostfix)) {
             ++methodPostfix;
           }
         }
       }
     }
   }
   return remapper;
 }
コード例 #20
0
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.ui.tests.harness.util.UITestCase#doTearDown()
  */
 protected void doTearDown() throws Exception {
   handlerService.deactivateHandlers(testHandlerActivations.values());
   testHandlerActivations.clear();
   contextService.deactivateContexts(testContextActivations.values());
   testContextActivations.clear();
   super.doTearDown();
 }
コード例 #21
0
  public Collection getLikelyPrivileges(String name) {
    buildBusinessPrivilegeTree();
    buildNonRolePrivilegeTree();

    Collection result = new LinkedList();
    for (Iterator iter = allBusinessPrivilegesMap.values().iterator(); iter.hasNext(); ) {
      Privilege pvlg = (Privilege) iter.next();
      if (pvlg.getName().contains(name)) {
        result.add(pvlg);
      }
    }

    for (Iterator iter = allNonRolePrivilegesMap.values().iterator(); iter.hasNext(); ) {
      Privilege pvlg = (Privilege) iter.next();
      if (pvlg.getName().contains(name)) {
        result.add(pvlg);
      }
    }

    return result;
    //		FieldWhereElement emt = new FieldWhereElement();
    //		emt.setColumn(table.getColumns()[2]);
    //		emt.setCompartor(SingleValueComparator.LIKE);
    //		emt.setContextValue(true);
    //		SelectCondition cdtn = new SelectCondition();
    //		cdtn.setWhereElement(emt);
    //		Privilege pvlg = new Privilege();
    //		pvlg.setName("%" + name + "%");
    //		return selector.select(cdtn, pvlg);
  }
コード例 #22
0
  private Collection<I_PP_MRP> getPP_MRPs_ToUse() {
    final Map<Integer, I_PP_MRP> mrps = new LinkedHashMap<>();

    //
    // Get MRP records that were explicitelly set
    for (final I_PP_MRP mrp : _mrps) {
      mrps.put(mrp.getPP_MRP_ID(), mrp);
    }
    // If we have MRP records explicitelly assigned, there is no point checking the MRP Context
    // because developer specified them and the ones from MRP context could be not relevant
    if (!mrps.isEmpty()) {
      return mrps.values();
    }

    //
    // Get MRP records from context
    final IMRPContext mrpContext = getMRPContext();
    if (mrpContext != null) {
      final I_PP_MRP mrp = mrpContext.getPP_MRP();
      if (mrp != null) {
        mrps.put(mrp.getPP_MRP_ID(), mrp);
      }
    }

    return mrps.values();
  }
コード例 #23
0
  public GraphIndex(Graph graph) {
    LOG.info("Indexing graph...");

    for (String feedId : graph.getFeedIds()) {
      for (Agency agency : graph.getAgencies(feedId)) {
        Map<String, Agency> agencyForId = agenciesForFeedId.getOrDefault(feedId, new HashMap<>());
        agencyForId.put(agency.getId(), agency);
        this.agenciesForFeedId.put(feedId, agencyForId);
      }
    }

    Collection<Edge> edges = graph.getEdges();
    /* We will keep a separate set of all vertices in case some have the same label.
     * Maybe we should just guarantee unique labels. */
    Set<Vertex> vertices = Sets.newHashSet();
    for (Edge edge : edges) {
      vertices.add(edge.getFromVertex());
      vertices.add(edge.getToVertex());
      if (edge instanceof TablePatternEdge) {
        TablePatternEdge patternEdge = (TablePatternEdge) edge;
        TripPattern pattern = patternEdge.getPattern();
        patternForId.put(pattern.code, pattern);
      }
    }
    for (Vertex vertex : vertices) {
      vertexForId.put(vertex.getLabel(), vertex);
      if (vertex instanceof TransitStop) {
        TransitStop transitStop = (TransitStop) vertex;
        Stop stop = transitStop.getStop();
        stopForId.put(stop.getId(), stop);
        stopVertexForStop.put(stop, transitStop);
        stopsForParentStation.put(stop.getParentStation(), stop);
      }
    }
    for (TransitStop stopVertex : stopVertexForStop.values()) {
      Envelope envelope = new Envelope(stopVertex.getCoordinate());
      stopSpatialIndex.insert(envelope, stopVertex);
    }
    for (TripPattern pattern : patternForId.values()) {
      patternsForFeedId.put(pattern.getFeedId(), pattern);
      patternsForRoute.put(pattern.route, pattern);

      for (Trip trip : pattern.getTrips()) {
        patternForTrip.put(trip, pattern);
        tripForId.put(trip.getId(), trip);
      }
      for (Stop stop : pattern.getStops()) {
        patternsForStop.put(stop, pattern);
      }
    }
    for (Route route : patternsForRoute.asMap().keySet()) {
      routeForId.put(route.getId(), route);
    }

    // Copy these two service indexes from the graph until we have better ones.
    calendarService = graph.getCalendarService();
    serviceCodes = graph.serviceCodes;
    this.graph = graph;
    LOG.info("Done indexing graph.");
  }
コード例 #24
0
ファイル: ClusterManager.java プロジェクト: ravib777/hornetq
  /**
   * Activates several cluster services. Used by backups on failover.
   *
   * @throws Exception
   */
  public synchronized void activate() throws Exception {
    if (state != State.STARTED && state != State.DEPLOYED) return;

    if (backup) {
      backup = false;

      deployConfiguredBridges();

      for (BroadcastGroup broadcastGroup : broadcastGroups.values()) {
        try {
          broadcastGroup.start();
        } catch (Exception e) {
          HornetQServerLogger.LOGGER.unableToStartBroadcastGroup(e, broadcastGroup.getName());
        }
      }

      for (ClusterConnection clusterConnection : clusterConnections.values()) {
        try {
          clusterConnection.activate();
        } catch (Exception e) {
          HornetQServerLogger.LOGGER.unableToStartClusterConnection(e, clusterConnection.getName());
        }
      }

      for (Bridge bridge : bridges.values()) {
        try {
          bridge.start();
        } catch (Exception e) {
          HornetQServerLogger.LOGGER.unableToStartBridge(e, bridge.getName());
        }
      }
    }
  }
コード例 #25
0
 @Override
 public ProviderInfo resolveContentProvider(String name, int flags) throws RemoteException {
   waitForReadyInner();
   try {
     enforcePluginFileExists();
     if (shouldNotBlockOtherInfo()) {
       for (PluginPackageParser pluginPackageParser : mPluginCache.values()) {
         List<ProviderInfo> providerInfos = pluginPackageParser.getProviders();
         for (ProviderInfo providerInfo : providerInfos) {
           if (TextUtils.equals(providerInfo.authority, name)) {
             return providerInfo;
           }
         }
       }
     } else {
       List<String> pkgs = mActivityManagerService.getPackageNamesByPid(Binder.getCallingPid());
       for (PluginPackageParser pluginPackageParser : mPluginCache.values()) {
         List<ProviderInfo> providerInfos = pluginPackageParser.getProviders();
         for (ProviderInfo providerInfo : providerInfos) {
           if (TextUtils.equals(providerInfo.authority, name)
               && pkgs.contains(providerInfo.packageName)) {
             return providerInfo;
           }
         }
       }
     }
   } catch (Exception e) {
     handleException(e);
   }
   return null;
 }
コード例 #26
0
  @Override
  public void execute(Tuple tuple) {
    List<Object> id = tuple.select(_idFields);
    GlobalStreamId streamId =
        new GlobalStreamId(tuple.getSourceComponent(), tuple.getSourceStreamId());
    if (!_pending.containsKey(id)) {
      _pending.put(id, new HashMap<GlobalStreamId, Tuple>());
    }
    Map<GlobalStreamId, Tuple> parts = _pending.get(id);
    if (parts.containsKey(streamId))
      throw new RuntimeException("Received same side of single join twice");
    parts.put(streamId, tuple);
    if (parts.size() == _numSources) {
      _pending.remove(id);
      List<Object> joinResult = new ArrayList<Object>();
      for (String outField : _outFields) {
        GlobalStreamId loc = _fieldLocations.get(outField);
        joinResult.add(parts.get(loc).getValueByField(outField));
      }
      _collector.emit(new ArrayList<Tuple>(parts.values()), joinResult);

      for (Tuple part : parts.values()) {
        _collector.ack(part);
      }
    }
  }
コード例 #27
0
ファイル: MultipageWizard.java プロジェクト: alevy/comet
  public void performNext() {
    if (true == pages.isEmpty()) {
      return;
    }

    if (null == currentPage) {
      IWizardPage page = (IWizardPage) pages.values().iterator().next();
      showPage(page.getPageID());
    } else {
      boolean foundCurrent = false;
      for (Iterator iterator = pages.values().iterator(); iterator.hasNext(); ) {
        IWizardPage page = (IWizardPage) iterator.next();
        if (true == foundCurrent) {
          showPage(page.getPageID());
          return;
        }

        if (page.getPageID().equals(currentPage.getPageID())) {
          foundCurrent = true;
        }
      }

      if (false == foundCurrent) {
        Debug.out("MultipageWizard:: there is no more page to go to");
      }
    }
  }
コード例 #28
0
ファイル: ItemDetailFragment.java プロジェクト: bpingar/Arias
    @Override
    protected Integer doInBackground(final String... strings) {
      Log.e("1", "Entra en doInBackground");

      final Map<Long, Marca> marcasExtraidas = extraerMarcas();
      final List<Marca> marcasExistentesBD = databaseHelper.getMarcaDAO().queryForAll();
      final Map<Long, Marca> marcasExistentes = new HashMap<Long, Marca>();
      for (final Marca marcaExistenteBD : marcasExistentesBD) {
        marcasExistentes.put(marcaExistenteBD.getId(), marcaExistenteBD);
      }

      Marca marcaExtraida;
      for (final Marca marcaExistente : marcasExistentes.values()) {
        if ((marcaExtraida = marcasExtraidas.get(marcaExistente.getId())) == null) {
          marcaExistente.setActivo(false);
        } else {
          marcaExistente.setActivo(true);
          marcaExistente.setMarca(marcaExtraida.getMarca());
          marcaExistente.setDescripcion(marcaExtraida.getDescripcion());
        }
        databaseHelper.getMarcaDAO().update(marcaExistente);
        Log.e("Actualizada marca: ", marcaExistente.getId().toString());
      }
      for (final Marca marcaExtraida2 : marcasExtraidas.values()) {
        if (marcasExistentes.get(marcaExtraida2.getId()) == null) {
          databaseHelper.getMarcaDAO().create(marcaExtraida2);
          Log.e("Insertada marca: ", marcaExtraida2.getId().toString());
        }
      }

      Log.e("Entra doInBackground", "1");
      return 1;
    }
コード例 #29
0
ファイル: ClusterManagerImpl.java プロジェクト: alesj/hornetq
  // backup node becomes live
  public synchronized void activate() {
    if (backup) {
      backup = false;

      for (BroadcastGroup broadcastGroup : broadcastGroups.values()) {
        try {
          broadcastGroup.start();
          broadcastGroup.activate();
        } catch (Exception e) {
          log.warn("unable to start broadcast group " + broadcastGroup.getName(), e);
        }
      }

      for (ClusterConnection clusterConnection : clusterConnections.values()) {
        try {
          clusterConnection.activate();
        } catch (Exception e) {
          log.warn("unable to start cluster connection " + clusterConnection.getName(), e);
        }
      }

      for (Bridge bridge : bridges.values()) {
        try {
          bridge.start();
        } catch (Exception e) {
          log.warn("unable to start bridge " + bridge.getName(), e);
        }
      }
    }
  }
コード例 #30
0
 private MethodDeclaration createCleanup() {
   List<Statement> statements = Lists.create();
   for (SimpleName name : shuffleNames.values()) {
     statements.add(
         new ExpressionBuilder(factory, factory.newThis())
             .field(name)
             .assignFrom(Models.toNullLiteral(factory))
             .toStatement());
   }
   for (SimpleName name : rendezvousNames.values()) {
     statements.add(
         new ExpressionBuilder(factory, factory.newThis())
             .field(name)
             .assignFrom(Models.toNullLiteral(factory))
             .toStatement());
   }
   return factory.newMethodDeclaration(
       null,
       new AttributeBuilder(factory).annotation(t(Override.class)).Public().toAttributes(),
       Collections.<TypeParameterDeclaration>emptyList(),
       t(void.class),
       factory.newSimpleName("cleanup"),
       Collections.singletonList(
           factory.newFormalParameterDeclaration(
               factory.newNamedType(factory.newSimpleName("Context")), context)),
       0,
       Arrays.asList(t(IOException.class), t(InterruptedException.class)),
       factory.newBlock(statements));
 }