예제 #1
0
  /**
   * Searches zero locations in a neigboorhood in a code piece, starts a number of search threads
   *
   * @param cp The code piece
   * @param globalValues The global initialised values
   * @return The zero locations points
   */
  private LinkedList<Point3d> searchZeroLocations(
      CodePiece cp,
      HashMap<MultivectorComponent, Double> globalValues,
      int a,
      float dist,
      double epsilon,
      boolean renderIn2d) {
    LinkedList<Point3d> points = new LinkedList<Point3d>();

    int processorCount = Runtime.getRuntime().availableProcessors();

    RayMethodThread[] threads = new RayMethodThread[processorCount];
    for (int i = 0; i < processorCount; i++) {
      float from = (i * 2 * a) / ((float) processorCount) - a;
      float to =
          ((i != processorCount - 1) ? ((i + 1) * 2 * a) / ((float) processorCount) : 2 * a) - a;

      threads[i] = new RayMethodThread(from, to, a, dist, globalValues, cp, epsilon, renderIn2d);
      threads[i].start();
    }

    for (int i = 0; i < threads.length; i++) {
      try {
        threads[i].join();
        points.addAll(threads[i].points);
      } catch (InterruptedException ex) {
        Logger.getLogger(DiscreteCubeMethod.class.getName()).log(Level.SEVERE, null, ex);
      }
    }

    return points;
  }
예제 #2
0
 /*
  * Removes the URI at the top of the stack of URIs to which the given
  * prefix is mapped.
  *
  * @param prefix The prefix whose stack of URIs is to be popped
  */
 public void popPrefixMapping(String prefix) {
   LinkedList stack = (LinkedList) xmlPrefixMapper.get(prefix);
   if (stack == null || stack.size() == 0) {
     // XXX throw new Exception("XXX");
   }
   stack.removeFirst();
 }
예제 #3
0
 /** Show the last element in the list of adapters */
 private void showList() {
   if (mAdapters.isEmpty() || mAdapters.getLast().isEmpty()) {
     mList.setEmptyView(mEmptyLibrary);
   } else {
     LibraryAdapter adapter = mAdapters.getLast();
     adapter.getFilter().filter(mLastFilter);
     mList.setAdapter(adapter);
     if (adapter.isEmpty() || adapter.getCount() == 0) {
       buildSubActionBar("", "");
     } else {
       MyLibraryItem item = adapter.getItem(0);
       switch (item.getLevel()) {
         case MyLibrary.LVL_ARTIST:
           buildSubActionBar("", "");
           break;
         case MyLibrary.LVL_ALBUM:
           buildSubActionBar(item.getArtist(), "");
           break;
         default:
           buildSubActionBar(item.getArtist(), item.getAlbum());
           break;
       }
     }
   }
 }
  /**
   * Get the resource name given a full filename.
   *
   * @param fileName the full filename (which must be inside the directory)
   * @return the resource name (i.e., the filename with the directory stripped off)
   */
  String getResourceName(String fileName) {
    // FIXME: there is probably a more robust way to do this

    // Strip off the directory part.
    String dirPath = directory.getPath();
    if (!fileName.startsWith(dirPath)) {
      throw new IllegalStateException("Filename " + fileName + " not inside directory " + dirPath);
    }

    // The problem here is that we need to take the relative part of the filename
    // and break it into components that we can then reconstruct into
    // a resource name (using '/' characters to separate the components).
    // Unfortunately, the File class does not make this task particularly easy.

    String relativeFileName = fileName.substring(dirPath.length());
    File file = new File(relativeFileName);
    LinkedList<String> partList = new LinkedList<String>();
    do {
      partList.addFirst(file.getName());
    } while ((file = file.getParentFile()) != null);

    StringBuilder buf = new StringBuilder();
    for (String part : partList) {
      if (buf.length() > 0) {
        buf.append('/');
      }
      buf.append(part);
    }

    return buf.toString();
  }
예제 #5
0
  /* Search recursively for all SBML files in given path. */
  public static LinkedList<String> walk(String path) {
    LinkedList<String> sbmlList = new LinkedList<String>();

    File root = new File(path);
    File[] list = root.listFiles();

    if (list == null) {
      return sbmlList;
    }

    for (File f : list) {
      if (f.isDirectory()) {
        sbmlList.addAll(walk(f.getAbsolutePath()));
        // System.out.println( "Dir:" + f.getAbsoluteFile() );
      } else {
        // System.out.println( "File:" + f.getAbsoluteFile() );
        String fname = f.getName();
        if (fname.endsWith(".xml") && fname.contains("pass") && !skip.contains(fname)) {

          // System.out.println( "SBML:" + f.getAbsoluteFile() );
          sbmlList.add(f.getAbsolutePath());
        }
      }
    }
    return sbmlList;
  }
예제 #6
0
 @Test(timeout = 5 * 60 * 1000)
 public void testJNIMemoryManagerHeapExpansion() {
   LinkedList<RefCountedTester> heldRefs = new LinkedList<RefCountedTester>();
   JNIMemoryManager mgr = JNIMemoryManager.getMgr();
   mgr.flush();
   mgr.setMinimumReferencesToCache(1024);
   int maxItems = 10000;
   // 10000 should cause several heap expansions to occur
   for (int i = 0; i < maxItems; i++) {
     heldRefs.add(RefCountedTester.make());
   }
   assertEquals("didn't pin as many as it should", maxItems, mgr.getNumPinnedObjects());
   // now release them.
   heldRefs.clear();
   while (mgr.getNumPinnedObjects() != 0) {
     MemoryTestHelper.forceJavaHeapWeakReferenceClear();
     // Do a collection
     mgr.gc(true);
   }
   assertEquals("didn't pin as many as it should", 0, mgr.getNumPinnedObjects());
   // this should cause the heap to shrink, and then grow
   for (int i = 0; i < maxItems / 2; i++) {
     heldRefs.add(RefCountedTester.make());
   }
   assertEquals("didn't pin as many as it should", maxItems / 2, mgr.getNumPinnedObjects());
   // now release them.
   heldRefs.clear();
   // and force a collection
   while (mgr.getNumPinnedObjects() != 0) {
     MemoryTestHelper.forceJavaHeapWeakReferenceClear();
     // Do a collection
     mgr.gc(true);
   }
   assertEquals("didn't pin as many as it should", 0, mgr.getNumPinnedObjects());
 }
예제 #7
0
파일: ForHandler.java 프로젝트: kacper-/gai
 @Override
 public Object handle() throws GAIInterpreterException {
   String condition = getFirstMatch(getCommand(), RH.VAL_OR_EXP);
   String action = getActionName(getCommand().replace(condition, ""));
   LinkedList<GAIObject> actionChain = getSession().getObjectOrAttribute(action);
   if (isPathValid(action)) {
     throw new GAIInterpreterException(wrongPath(actionChain));
   }
   Object result;
   AbstractHandler handler;
   if (hasMatch(condition, RH.ANY_VAL)) {
     result = getValue(condition);
   } else if (hasMatch(condition, RH.NUMERIC_EXP)) {
     handler = new NumericExpHandler(condition, getInterpreter());
     result = handler.handle();
   } else if (hasMatch(condition, RH.ACT_EXE)) {
     handler = new ActionExecHandler(condition, getInterpreter());
     result = handler.handle();
   } else {
     throw new GAIInterpreterException(INVALID_FOR_CONDITION);
   }
   if (result == null) {
     throw new GAIInterpreterException(INVALID_FOR_CONDITION);
   }
   if (isArray(result)) {
     GAIObject arrayObject = (GAIObject) result;
     for (Object e : arrayObject.getElements()) {
       executeAction(actionChain.getLast(), e);
     }
   } else {
     executeAction(actionChain.getLast(), result);
   }
   return null;
 }
  public static LinkedList<String> readFromFile() {
    File f;
    Scanner scanner;
    LinkedList<String> result = new LinkedList<>();

    try {
      f = new File(fileName);
      scanner = new Scanner(f);
      // Pattern regex = Pattern.compile("\\w");

      while (scanner.hasNext()) {
        String current = scanner.next();
        String[] splitLine = current.split(",");

        for (int i = 0; i < splitLine.length; i++) {
          // Debug statement
          System.out.println("Scanner adding to list:" + splitLine[i]);
          result.add(splitLine[i]);
        }

        System.out.println("Scanner reading:" + current);
        // result.add(current);
        // System.out.println("Output of file" + );
      }

      return result;
    } catch (IOException exc) {
      System.out.println("Error reading file line" + exc.getMessage());
    }
    return null;
  }
예제 #9
0
 public void printNodes() {
   System.out.println("[NodeList]");
   for (int i = 0; i < nodeList.size(); i++) {
     System.out.println("\t" + nodeList.get(i).toString());
   }
   System.out.println("[/NodeList]");
 }
예제 #10
0
  /**
   * Change the status This is the master function which may change the status of one or more
   * instances.
   */
  public static void changeStatus(int status, String messageText) {
    if (Preferences.getBoolean("jeti", "statusLinked", true)) {
      for (Iterator i = subInstances.iterator(); i.hasNext(); ) {
        StatusButton sub = (StatusButton) i.next();
        sub.changeInstanceStatus(status, messageText);
      }
      master.changeInstanceStatus(status, messageText);

    } else {
      if (currentParent == master || currentParent == null) {
        for (Iterator i = subInstances.iterator(); i.hasNext(); ) {
          StatusButton sub = (StatusButton) i.next();
          if (sub.status == master.status
              && ((sub.message == null && master.message == null)
                  || (sub.message != null && sub.message.equals(master.message)))) {
            sub.changeInstanceStatus(status, messageText);
          }
        }
      }
      if (currentParent != null) {
        currentParent.changeInstanceStatus(status, messageText);
      } else {
        master.changeInstanceStatus(status, messageText);
      }
    }
  }
예제 #11
0
 private List<Number> initList(LinkedList<Number> list) {
   list.add(new Double(1000f));
   list.add(new Double("123e-445632"));
   list.add(new Float(-90 / -3));
   list.remove(new Double("123e-445632"));
   return list;
 }
예제 #12
0
 /**
  * Overriden superclass method. Calls super.init() and also initializes the MuleContext
  *
  * @see SpringServicesContainer#init()
  */
 public void init() throws PlatformException {
   super.init();
   LinkedList<String> fileNamesList = new LinkedList<String>();
   // add the common Mule beans file
   fileNamesList.add(SedaFrameworkConstants.COMMON_MULE_CONFIG);
   // add the Mule configurations containing Mule service definitions
   File[] serviceBeansFiles = FileLocator.findFiles(SedaFrameworkConstants.MULE_CONFIG);
   for (File serviceBeansFile : serviceBeansFiles) {
     fileNamesList.add(serviceBeansFile.getAbsolutePath());
   }
   String[] muleConfigPaths = (String[]) fileNamesList.toArray(new String[0]);
   try {
     SpringXmlConfigurationBuilder springConfigBuilder =
         new SpringXmlConfigurationBuilder(muleConfigPaths);
     springConfigBuilder.setUseDefaultConfigResource(
         false); // turn off using the default config resource as we have a custom config defined
     // in SedaFrameworkConstants.COMMON_MULE_CONFIG
     springConfigBuilder.setParentContext(this.servicesContext);
     this.muleContext = new DefaultMuleContextFactory().createMuleContext(springConfigBuilder);
     this.muleContext.start();
   } catch (Exception e) {
     LOGGER.error("Fatal error loading Mule configurations : " + e.getMessage(), e);
     throw new PlatformException("Fatal error loading Mule configurations : " + e.getMessage(), e);
   }
 }
예제 #13
0
 public BehaviorInfo popBehavior() {
   if (!behaviorStack.isEmpty()) {
     return behaviorStack.removeFirst();
   } else {
     return null;
   }
 }
예제 #14
0
파일: JsonUtil.java 프로젝트: tyhu/Git
 /**
  * Convert the items in the list to a JsonUtil array of JsonUtil objects, and remove these objects
  * from the list. Currently only String fields are supported.
  *
  * @param list The list as the source of objects to be converted to JsonUtil array.
  * @param cnt The number of objects to be converted, and deleted from the list. e.g. cnt = 10
  *     means list[0] to list[9] will be converted and deleted.
  */
 public static String linkedList2Json(ConcurrentLinkedQueue list, int cnt) {
   StringBuilder sb = new StringBuilder();
   // List sub = list..subList(0, cnt);
   LinkedList sub = new LinkedList();
   for (int i = 0; i < cnt; i++) sub.add(list.poll());
   Field[] fields = null;
   Class cls = null;
   // create a json array
   sb.append("{\"objects\":[");
   boolean firstObject = true;
   for (Object obj : sub) {
     if (firstObject) {
       sb.append("{");
       firstObject = false;
     } else {
       sb.append(", {");
     }
     if (fields == null) {
       fields = obj.getClass().getFields();
       cls = obj.getClass();
     }
     // do sth to retrieve each field value -> json property of json object
     // add to json array
     for (int i = 0; i < fields.length; i++) {
       Field f = fields[i];
       jsonFromField(sb, obj, i, f);
     }
     sb.append("}");
   }
   sb.append("]}");
   sub.clear();
   return sb.toString();
 }
예제 #15
0
 /**
  * Re-validates all lockout data to determine if failed attempts have aged sufficiently to be
  * "forgotten" about, if a user is locked out due to failed attempts, and if a lock should be
  * released due to age.
  *
  * <p>This should be called at the start of any method that either checks for or updates a lockout
  * condition.
  */
 private synchronized void revalidateLockouts() {
   LOG.debug("Revalidating lockouts");
   long now = System.currentTimeMillis();
   // clean out any failed logins that are older than _attemptMemoryDuration_
   for (String userId : failedLogins.keySet()) {
     LinkedList<Long> attempts = failedLogins.get(userId);
     Iterator<Long> reverseAttempts = new ReverseIterator<Long>(attempts);
     while (reverseAttempts.hasNext()) {
       Long attemptTime = reverseAttempts.next();
       if ((now - attemptTime.longValue()) > attemptMemoryDuration) {
         LOG.debug("Forgetting old failed login attempt for " + userId);
         reverseAttempts.remove();
       }
     }
     // if the user still has more than _maxFailedAttempts_ bad logins, they get locked out iff
     // they're not ALREADY locked out
     if (attempts.size() >= maxFailedAttempts && !lockedOutUsers.containsKey(userId)) {
       lockedOutUsers.put(userId, Long.valueOf(now + lockoutDuration));
       LOG.debug("Locked out user " + userId + " for " + lockoutDuration + "ms");
     }
   }
   // purge any lockouts older than _lockoutDuration_
   List<String> lockedOutIds = new ArrayList<String>(lockedOutUsers.keySet());
   for (String userId : lockedOutIds) {
     Long endOfLockout = lockedOutUsers.get(userId);
     if (now >= endOfLockout.longValue()) {
       lockedOutUsers.remove(userId);
       LOG.debug("Removed expired lockout for user " + userId);
     } else if (LOG.isDebugEnabled()) {
       LOG.debug(
           "User " + userId + " still locked out for " + (endOfLockout.longValue() - now) + "ms");
     }
   }
 }
예제 #16
0
 public JLocalVariable getLocalVariable(int index) {
     for (int i = 0; i < localVariables.size(); i++) {
         if (((JLocalVariable)localVariables.get(i)).index == index)
             return (JLocalVariable)localVariables.get(i);
     }
     return null;
 }
 protected List<Object> listOf(Object... objects) {
   LinkedList<Object> list = new LinkedList<Object>();
   for (Object object : objects) {
     list.add(object);
   }
   return list;
 }
예제 #18
0
 void computeIn(LinkedList<Vertex> worklist) {
   int i;
   BitSet old;
   BitSet ne;
   Vertex v;
   ListIterator<Vertex> iter;
   iter = succ.listIterator();
   while (iter.hasNext()) {
     v = iter.next();
     out.or(v.in);
   }
   old = in;
   in = new BitSet();
   in.or(out);
   in.andNot(def);
   in.or(use);
   if (!in.equals(old)) {
     iter = pred.listIterator();
     while (iter.hasNext()) {
       v = iter.next();
       if (!v.listed) {
         worklist.addLast(v);
         v.listed = true;
       }
     }
   }
 }
예제 #19
0
 public void doFilter(HttpExchange exchange) throws IOException {
   if (filters.isEmpty()) {
     context.getHandler().handle(exchange);
   } else {
     filters.removeFirst().doFilter(exchange, this);
   }
 }
예제 #20
0
 /**
  * @param grid
  * @return an array of vertex coordinates, one vertex per edge end, 3 coords per vertex
  */
 public double[] getCoords(float[][] grid) {
   double[] ret = new double[edges.size() * 3];
   Iterator<Integer> it = edges.iterator();
   switch (direction) {
     case 0:
       for (int i = 0; i < ret.length; i += 3) {
         ret[i + 0] = grid[0][it.next().intValue()];
         ret[i + 1] = grid[1][c1];
         ret[i + 2] = grid[2][c2];
       }
       break;
     case 1:
       for (int i = 0; i < ret.length; i += 3) {
         ret[i + 0] = grid[0][c1];
         ret[i + 1] = grid[1][it.next().intValue()];
         ret[i + 2] = grid[2][c2];
       }
       break;
     case 2:
       for (int i = 0; i < ret.length; i += 3) {
         ret[i + 0] = grid[0][c1];
         ret[i + 1] = grid[1][c2];
         ret[i + 2] = grid[2][it.next().intValue()];
       }
       break;
   }
   return ret;
 }
예제 #21
0
 public static LinkedList<String> listaConsigliDaSingoloTag(String tag) {
   LinkedList<String> result = new LinkedList<>();
   for (Track track : AusiliariParte1.consigliDaSingoloTag(tag)) {
     result.add(track.getName());
   }
   return result;
 }
예제 #22
0
  /**
   * maintains a list of last <i>committedLog</i> or so committed requests. This is used for fast
   * follower synchronization.
   *
   * @param request committed request
   */
  public void addCommittedProposal(Request request) {
    WriteLock wl = logLock.writeLock();
    try {
      wl.lock();
      if (committedLog.size() > commitLogCount) {
        committedLog.removeFirst();
        minCommittedLog = committedLog.getFirst().packet.getZxid();
      }
      if (committedLog.isEmpty()) {
        minCommittedLog = request.zxid;
        maxCommittedLog = request.zxid;
      }

      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      BinaryOutputArchive boa = BinaryOutputArchive.getArchive(baos);
      try {
        request.getHdr().serialize(boa, "hdr");
        if (request.getTxn() != null) {
          request.getTxn().serialize(boa, "txn");
        }
        baos.close();
      } catch (IOException e) {
        LOG.error("This really should be impossible", e);
      }
      QuorumPacket pp = new QuorumPacket(Leader.PROPOSAL, request.zxid, baos.toByteArray(), null);
      Proposal p = new Proposal();
      p.packet = pp;
      p.request = request;
      committedLog.add(p);
      maxCommittedLog = p.packet.getZxid();
    } finally {
      wl.unlock();
    }
  }
 /**
  * Calculate largest prime factor.
  *
  * @return the largest prime factor
  */
 public int getLargestPrimeFactor() {
   int divider = PrimeChecker.FIRST_PRIME;
   double divideIt = this.divideIt;
   this.factors.addLast(PrimeChecker.FIRST_PRIME);
   while (divideIt > 1) {
     if (String.valueOf(divideIt).endsWith(String.valueOf(PrimeChecker.END_PRIME))) {
       divider = PrimeChecker.END_PRIME;
       divideIt = divideIt / divider;
     } else {
       boolean hasNext = false;
       for (final int prime : this.factors) {
         if (divideIt % prime == 0) {
           divider = prime;
           hasNext = true;
           break;
         }
       }
       if (!hasNext) {
         while (divideIt % divider == 0) {
           this.factors.addLast(divider);
           divider = PrimeChecker.getNextPrime(this.factors);
         }
         hasNext = false;
       }
     }
     divideIt = divideIt / divider;
     if (!factors.contains(divider)) {
       factors.add(divider);
     }
   }
   System.out.println("processed primes : " + factors.toString());
   return factors.getLast();
 }
예제 #24
0
  public synchronized boolean enqueue(ByteBuffer byteBuffer) {
    if (byteBuffer.remaining() == 0) {
      return false;
    }

    if (queue.size() > 0) {
      ByteBuffer tail = queue.getLast();

      if (tail.hasRemaining()) {
        topUpBuffer(tail, byteBuffer);
      }
    }

    while (byteBuffer.hasRemaining()) {
      ByteBuffer newBuf = bufferFactory.newBuffer();

      topUpBuffer(newBuf, byteBuffer);

      queue.addLast(newBuf);
    }

    facade.modifyInterestOps(SelectionKey.OP_WRITE, 0);

    return true;
  }
예제 #25
0
  // Declare parameters
  @Parameters(name = "{index}: {0}")
  public static Iterable<Object[]> data() {
    System.out.println("Working Directory = " + System.getProperty("user.dir"));
    File currentDir = new File(System.getProperty("user.dir"));
    String rootPath = new File(currentDir, "src/test/resources/models/sbml-test-cases").getPath();
    // Get all the SBML files
    LinkedList<String> sbmlPaths = walk(rootPath);

    int N = sbmlPaths.size();
    System.out.println("Number of SBML test cases: " + N);
    Object[][] resources = new String[N][1];
    for (int k = 0; k < N; k++) {
      String path = sbmlPaths.get(k);
      // create the resource
      String[] items = path.split("/");
      int mindex = -1;
      for (int i = 0; i < items.length; i++) {
        if (items[i].equals("models")) {
          mindex = i;
          break;
        }
      }
      String resource = StringUtils.join(ArrayUtils.subarray(items, mindex, items.length), "/");
      // System.out.println(resource);
      resources[k][0] = "/" + resource; // String.format("/models/BiGG/%s", fname);
    }
    return Arrays.asList(resources);
  }
예제 #26
0
파일: Test9.java 프로젝트: w20090905/nebula
  static void printGraph(String msg, LinkedList<Item>[] buf) {
    System.out.print("\n================================================\n" + msg);

    for (int row = 0; row < 9; row++) {
      System.out.println("\n");
      InnerFor:
      for (int column = 0; column < 9; column++) {
        System.out.print("\t");
        LinkedList<Item> e = buf[row * 9 + column];
        if (e.size() == 1) System.out.print("[" + e.getFirst().value + "]");
        else {
          for (Item t : e) {
            if (t.status == ItemStatus.ForceOK) {
              System.out.print("<" + t.value + ">");
              continue InnerFor;
            }
          }
          for (Item t : e) {
            if (t.status == ItemStatus.OK) {
              System.out.print("(" + t.value + ")");
              continue InnerFor;
            }
          }
          for (Item t : e) {
            if (t.status == ItemStatus.MaybeOK) System.out.print("" + t.value + "");
          }
          for (Item t : e) {
            if (t.status == ItemStatus.MaybeNot) System.out.print("-" + t.value + "");
          }
        }
      }
    }
  }
예제 #27
0
 private boolean addSongsToPlaylist(MyLibraryItem libraryItem) {
   switch (libraryItem.getLevel()) {
     case MyLibrary.LVL_ARTIST:
       MyLibrary addArtist = new MyLibrary(getActivity());
       addArtist.addOnLibrarySelectFinishedListener(LibraryFragment.this);
       addArtist.getAllTitlesFromArtistAsync(libraryItem.getArtist());
       return true;
     case MyLibrary.LVL_ALBUM:
       MyLibrary addAlbums = new MyLibrary(getActivity());
       addAlbums.addOnLibrarySelectFinishedListener(LibraryFragment.this);
       addAlbums.getTitlesAsync(libraryItem.getArtist(), libraryItem.getAlbum());
       return true;
     case MyLibrary.LVL_TITLE:
       Message msg = Message.obtain();
       LinkedList<String> urls = new LinkedList<String>();
       urls.add(libraryItem.getUrl());
       msg.obj =
           ClementineMessageFactory.buildInsertUrl(
               App.mClementine.getPlaylistManager().getActivePlaylistId(), urls);
       App.mClementineConnection.mHandler.sendMessage(msg);
       return false;
     default:
       return false;
   }
 }
예제 #28
0
    public String hasSameContent(JarFile2 file, JarEntry entry) throws IOException {

      String thisName = null;

      Long crcL = new Long(entry.getCrc());

      // check if this jar contains files with the passed in entry's crc
      if (_crcToEntryMap.containsKey(crcL)) {
        // get the Linked List with files with the crc
        LinkedList ll = (LinkedList) _crcToEntryMap.get(crcL);
        // go through the list and check for content match
        ListIterator li = ll.listIterator(0);
        if (li != null) {
          while (li.hasNext()) {
            JarEntry thisEntry = (JarEntry) li.next();

            // check for content match
            InputStream oldIS = getJarFile().getInputStream(thisEntry);
            InputStream newIS = file.getJarFile().getInputStream(entry);

            if (!differs(oldIS, newIS)) {
              thisName = thisEntry.getName();
              return thisName;
            }
          }
        }
      }

      return thisName;
    }
예제 #29
0
  /*
   * check to see if hit the limit for max # completed apps kept
   */
  protected synchronized void checkAppNumCompletedLimit() {
    // check apps kept in state store.
    while (completedAppsInStateStore > this.maxCompletedAppsInStateStore) {
      ApplicationId removeId = completedApps.get(completedApps.size() - completedAppsInStateStore);
      RMApp removeApp = rmContext.getRMApps().get(removeId);
      LOG.info(
          "Max number of completed apps kept in state store met:"
              + " maxCompletedAppsInStateStore = "
              + maxCompletedAppsInStateStore
              + ", removing app "
              + removeApp.getApplicationId()
              + " from state store.");
      rmContext.getStateStore().removeApplication(removeApp);
      completedAppsInStateStore--;
    }

    // check apps kept in memorty.
    while (completedApps.size() > this.maxCompletedAppsInMemory) {
      ApplicationId removeId = completedApps.remove();
      LOG.info(
          "Application should be expired, max number of completed apps"
              + " kept in memory met: maxCompletedAppsInMemory = "
              + this.maxCompletedAppsInMemory
              + ", removing app "
              + removeId
              + " from memory: ");
      rmContext.getRMApps().remove(removeId);
      this.applicationACLsManager.removeApplication(removeId);
    }
  }
 static void testObjectSensitivity1() {
   LinkedList<String> list1 = new LinkedList<String>();
   LinkedList<String> list2 = new LinkedList<String>();
   list1.add(taintedString("abcd")); // source
   list2.add("123");
   assert (getTaint(list2.getFirst()) == 0);
 }