Example #1
0
  public static void outputResult(Stock[] stocks, Exchange exchange) {

    for (Stock stock : stocks) {
      SortedSet<Bid> buyBidsList = exchange.getBuyBidsList(stock);
      System.out.println(
          " buy "
              + stock
              + "  "
              + buyBidsList.size()
              + "  at "
              + buyBidsList.last().getPrice()
              + " "
              + buyBidsList.first().getPrice());
      SortedSet<Bid> sellBidsList = exchange.getSellBidsList(stock);
      System.out.println(
          " sell "
              + stock
              + "  "
              + sellBidsList.size()
              + "  at "
              + sellBidsList.first().getPrice()
              + " "
              + sellBidsList.last().getPrice());
    }
  }
  @Test
  public void testDescribe() {
    for (String region : supportedRegions) {
      SortedSet<PlacementGroup> allResults =
          newTreeSet(client.getPlacementGroupApi().get().describePlacementGroupsInRegion(region));
      assertNotNull(allResults);
      if (allResults.size() >= 1) {
        PlacementGroup group = allResults.last();
        SortedSet<PlacementGroup> result =
            newTreeSet(
                client
                    .getPlacementGroupApi()
                    .get()
                    .describePlacementGroupsInRegion(region, group.getName()));
        assertNotNull(result);
        PlacementGroup compare = result.last();
        assertEquals(compare, group);
      }
    }

    for (String region :
        client.getAvailabilityZoneAndRegionApi().get().describeRegions().keySet()) {
      if (!supportedRegions.contains(region))
        try {
          client.getPlacementGroupApi().get().describePlacementGroupsInRegion(region);
          fail("should be unsupported for region: " + region);
        } catch (UnsupportedOperationException e) {
        }
    }
  }
  @Test
  void testDescribeAddresses() {
    for (String region : ec2Api.getConfiguredRegions()) {
      SortedSet<PublicIpInstanceIdPair> allResults =
          Sets.newTreeSet(client.describeAddressesInRegion(region));
      assertNotNull(allResults);
      if (!allResults.isEmpty()) {
        PublicIpInstanceIdPair pair = allResults.last();
        SortedSet<PublicIpInstanceIdPair> result =
            Sets.newTreeSet(client.describeAddressesInRegion(region, pair.getPublicIp()));
        assertNotNull(result);
        PublicIpInstanceIdPair compare = result.last();
        assertEquals(compare, pair);

        SortedSet<PublicIpInstanceIdPair> filterResult =
            Sets.newTreeSet(
                client.describeAddressesInRegionWithFilter(
                    region,
                    ImmutableMultimap.<String, String>builder()
                        .put("public-ip", pair.getPublicIp())
                        .build()));
        assertNotNull(filterResult);
        PublicIpInstanceIdPair filterCompare = filterResult.last();
        assertEquals(filterCompare, pair);
      }
    }
  }
  @Test
  void testDescribe() {
    for (String region : newArrayList(Region.US_EAST_1)) {
      SortedSet<PlacementGroup> allResults =
          newTreeSet(client.getPlacementGroupServices().describePlacementGroupsInRegion(region));
      assertNotNull(allResults);
      if (allResults.size() >= 1) {
        PlacementGroup group = allResults.last();
        SortedSet<PlacementGroup> result =
            newTreeSet(
                client
                    .getPlacementGroupServices()
                    .describePlacementGroupsInRegion(region, group.getName()));
        assertNotNull(result);
        PlacementGroup compare = result.last();
        assertEquals(compare, group);
      }
    }

    for (String region : client.getAvailabilityZoneAndRegionServices().describeRegions().keySet()) {
      if (!region.equals(Region.US_EAST_1))
        try {
          client.getPlacementGroupServices().describePlacementGroupsInRegion(region);
          assert false : "should be unsupported";
        } catch (UnsupportedOperationException e) {
        }
    }
  }
Example #5
0
 /** subSet returns set with keys in requested range */
 public void testDescendingSubSetContents() {
   NavigableSet set = dset5();
   SortedSet sm = set.subSet(m2, m4);
   assertEquals(m2, sm.first());
   assertEquals(m3, sm.last());
   assertEquals(2, sm.size());
   assertFalse(sm.contains(m1));
   assertTrue(sm.contains(m2));
   assertTrue(sm.contains(m3));
   assertFalse(sm.contains(m4));
   assertFalse(sm.contains(m5));
   Iterator i = sm.iterator();
   Object k;
   k = (Integer) (i.next());
   assertEquals(m2, k);
   k = (Integer) (i.next());
   assertEquals(m3, k);
   assertFalse(i.hasNext());
   Iterator j = sm.iterator();
   j.next();
   j.remove();
   assertFalse(set.contains(m2));
   assertEquals(4, set.size());
   assertEquals(1, sm.size());
   assertEquals(m3, sm.first());
   assertEquals(m3, sm.last());
   assertTrue(sm.remove(m3));
   assertTrue(sm.isEmpty());
   assertEquals(3, set.size());
 }
Example #6
0
 /** subSet returns set with keys in requested range */
 public void testSubSetContents() {
   NavigableSet set = set5();
   SortedSet sm = set.subSet(two, four);
   assertEquals(two, sm.first());
   assertEquals(three, sm.last());
   assertEquals(2, sm.size());
   assertFalse(sm.contains(one));
   assertTrue(sm.contains(two));
   assertTrue(sm.contains(three));
   assertFalse(sm.contains(four));
   assertFalse(sm.contains(five));
   Iterator i = sm.iterator();
   Object k;
   k = (Integer) (i.next());
   assertEquals(two, k);
   k = (Integer) (i.next());
   assertEquals(three, k);
   assertFalse(i.hasNext());
   Iterator j = sm.iterator();
   j.next();
   j.remove();
   assertFalse(set.contains(two));
   assertEquals(4, set.size());
   assertEquals(1, sm.size());
   assertEquals(three, sm.first());
   assertEquals(three, sm.last());
   assertTrue(sm.remove(three));
   assertTrue(sm.isEmpty());
   assertEquals(3, set.size());
 }
  private static void applyTiePointGeoCoding(
      TiffFileInfo info, double[] tiePoints, Product product) {
    final SortedSet<Double> xSet = new TreeSet<>();
    final SortedSet<Double> ySet = new TreeSet<>();
    for (int i = 0; i < tiePoints.length; i += 6) {
      xSet.add(tiePoints[i]);
      ySet.add(tiePoints[i + 1]);
    }
    final double xMin = xSet.first();
    final double xMax = xSet.last();
    final double xDiff = (xMax - xMin) / (xSet.size() - 1);
    final double yMin = ySet.first();
    final double yMax = ySet.last();
    final double yDiff = (yMax - yMin) / (ySet.size() - 1);

    final int width = xSet.size();
    final int height = ySet.size();

    int idx = 0;
    final Map<Double, Integer> xIdx = new HashMap<>();
    for (Double val : xSet) {
      xIdx.put(val, idx);
      idx++;
    }
    idx = 0;
    final Map<Double, Integer> yIdx = new HashMap<>();
    for (Double val : ySet) {
      yIdx.put(val, idx);
      idx++;
    }

    final float[] lats = new float[width * height];
    final float[] lons = new float[width * height];

    for (int i = 0; i < tiePoints.length; i += 6) {
      final int idxX = xIdx.get(tiePoints[i + 0]);
      final int idxY = yIdx.get(tiePoints[i + 1]);
      final int arrayIdx = idxY * width + idxX;
      lons[arrayIdx] = (float) tiePoints[i + 3];
      lats[arrayIdx] = (float) tiePoints[i + 4];
    }

    String[] names = Utils.findSuitableLatLonNames(product);
    final TiePointGrid latGrid =
        new TiePointGrid(names[0], width, height, xMin, yMin, xDiff, yDiff, lats);
    final TiePointGrid lonGrid =
        new TiePointGrid(names[1], width, height, xMin, yMin, xDiff, yDiff, lons);

    product.addTiePointGrid(latGrid);
    product.addTiePointGrid(lonGrid);
    final SortedMap<Integer, GeoKeyEntry> geoKeyEntries = info.getGeoKeyEntries();
    final Datum datum = getDatum(geoKeyEntries);
    product.setGeoCoding(new TiePointGeoCoding(latGrid, lonGrid, datum));
  }
Example #8
0
 @Override
 public String toString() {
   return "Depth{"
       + "symbol="
       + symbol
       + ", bids="
       + bids.first().rate()
       + "..."
       + bids.last().rate()
       + ", asks="
       + asks.first().rate()
       + "..."
       + asks.last().rate()
       + '}';
 }
Example #9
0
 @Test
 void testDescribeKeyPairs() {
   for (String region : ec2Api.getConfiguredRegions()) {
     SortedSet<KeyPair> allResults = Sets.newTreeSet(client.describeKeyPairsInRegion(region));
     assertNotNull(allResults);
     if (!allResults.isEmpty()) {
       KeyPair pair = allResults.last();
       SortedSet<KeyPair> result =
           Sets.newTreeSet(client.describeKeyPairsInRegion(region, pair.getKeyName()));
       assertNotNull(result);
       KeyPair compare = result.last();
       assertEquals(compare, pair);
     }
   }
 }
Example #10
0
 @Override
 protected SortedSet<Integer> create(Integer[] elements) {
   SortedSet<Integer> set = nullCheckedTreeSet(elements);
   int tooHigh = (set.isEmpty()) ? 0 : set.last() + 1;
   set.add(tooHigh);
   return checkedCreate(set).headSet(tooHigh);
 }
  @Test
  void testDescribeAWSKeyPairs() {
    for (String region : Region.DEFAULT_REGIONS) {

      SortedSet<KeyPair> allResults = newTreeSet(client.describeKeyPairsInRegion(region));
      assertNotNull(allResults);
      if (allResults.size() >= 1) {
        KeyPair pair = allResults.last();
        SortedSet<KeyPair> result =
            newTreeSet(client.describeKeyPairsInRegion(region, pair.getKeyName()));
        assertNotNull(result);
        KeyPair compare = result.last();
        assertEquals(compare, pair);
      }
    }
  }
  public PageSet<ObjectInfo> apply(InputStream stream) {
    checkState(args != null, "request should be initialized at this point");
    Type listType = new TypeToken<SortedSet<ObjectInfoImpl>>() {}.getType();

    try {
      SortedSet<ObjectInfoImpl> list = apply(stream, listType);
      SortedSet<ObjectInfo> returnVal =
          Sets.newTreeSet(
              Iterables.transform(
                  list,
                  new Function<ObjectInfoImpl, ObjectInfo>() {
                    public ObjectInfo apply(ObjectInfoImpl from) {
                      return from.toBuilder()
                          .container(container)
                          .uri(
                              uriBuilder(request.getEndpoint())
                                  .clearQuery()
                                  .appendPath(from.getName())
                                  .build())
                          .build();
                    }
                  }));
      boolean truncated = options.getMaxResults() == returnVal.size();
      String marker = truncated ? returnVal.last().getName() : null;
      return new PageSetImpl<ObjectInfo>(returnVal, marker);
    } catch (IOException e) {
      throw new RuntimeException("problem reading response from request: " + request, e);
    }
  }
Example #13
0
 public String enhanceSearchTaskExists() {
   String taskID = null;
   String queryUrlString =
       repository().getRepositoryUrl()
           + "/buglist.cgi?"
           + "short_desc=test%20EnhanceSearch&resolution=---&query_format=advanced"
           + "&short_desc_type=casesubstring&component=TestComponent&product=TestProduct";
   RepositoryQuery query =
       new RepositoryQuery(repository().getConnectorKind(), "handle-testQueryViaConnector");
   query.setUrl(queryUrlString);
   final Map<Integer, TaskData> changedTaskData = new HashMap<Integer, TaskData>();
   TaskDataCollector collector =
       new TaskDataCollector() {
         @Override
         public void accept(TaskData taskData) {
           changedTaskData.put(Integer.valueOf(taskData.getTaskId()), taskData);
         }
       };
   connector().performQuery(repository(), query, collector, null, new NullProgressMonitor());
   if (changedTaskData.size() > 0) {
     Set<Integer> ks = changedTaskData.keySet();
     SortedSet<Integer> sks = new TreeSet<Integer>(ks);
     taskID = sks.last().toString();
   }
   return taskID;
 }
Example #14
0
  /**
   * Given an inverted index finds the smallest window containing all the characters. Order of
   * appearance does not matter.
   *
   * @param invertedIndex - map where each character points to sorted list of its positions in the
   *     string; each character with in the index must appear in the source string at least once
   *     (i.e. must have non-empty list of positions).
   * @return positions of characters that belong to minimum window.
   */
  private static SortedSet<Integer> minWindow(Map<Character, List<Integer>> invertedIndex) {
    SortedMap<Integer, Iterator<Integer>> currentWindow = new TreeMap<Integer, Iterator<Integer>>();
    int entriesProcessed = 0;
    for (List<Integer> list : invertedIndex.values()) {
      Iterator<Integer> iterator = list.iterator();
      currentWindow.put(iterator.next(), iterator);
      entriesProcessed++;
    }
    SortedSet<Integer> minWindow = new TreeSet<Integer>(currentWindow.keySet());
    int minWindowLength = minWindow.last() - minWindow.first();

    Iterator<Integer> iterator = currentWindow.remove(currentWindow.firstKey());
    while (iterator.hasNext()) {
      currentWindow.put(iterator.next(), iterator);
      int currentWindowLength = currentWindow.lastKey() - currentWindow.firstKey();
      if (currentWindowLength < minWindowLength) {
        minWindow = new TreeSet<Integer>(currentWindow.keySet());
        minWindowLength = currentWindowLength;
      }
      iterator = currentWindow.remove(currentWindow.firstKey());
      entriesProcessed++;
    }
    System.out.println("Walked through " + entriesProcessed + " entries in inverted index.");
    return minWindow;
  }
 @Test
 void testDescribeAddresses() {
   for (String region : ec2Api.getConfiguredRegions()) {
     SortedSet<PublicIpInstanceIdPair> allResults =
         Sets.newTreeSet(client.describeAddressesInRegion(region));
     assertNotNull(allResults);
     if (allResults.size() >= 1) {
       PublicIpInstanceIdPair pair = allResults.last();
       SortedSet<PublicIpInstanceIdPair> result =
           Sets.newTreeSet(client.describeAddressesInRegion(region, pair.getPublicIp()));
       assertNotNull(result);
       PublicIpInstanceIdPair compare = result.last();
       assertEquals(compare, pair);
     }
   }
 }
Example #16
0
 public static void main(String[] args) {
   Scanner in = new Scanner(System.in);
   int arr[][] = new int[6][6];
   int sum = 0;
   for (int i = 0; i < 6; i++) {
     for (int j = 0; j < 6; j++) {
       arr[i][j] = in.nextInt();
     }
   }
   SortedSet<Integer> ts = new TreeSet<Integer>();
   for (int i = 0; i < 4; i++) {
     for (int j = 0; j < 4; j++) {
       sum =
           arr[i][j]
               + arr[i][j + 1]
               + arr[i][j + 2]
               + arr[i + 1][j + 1]
               + arr[i + 2][j]
               + arr[i + 2][j + 1]
               + arr[i + 2][j + 2];
       ts.add(sum);
     }
   }
   System.out.println(ts.last());
 }
  /** Test a TreeMultiset with a comparator that can return 0 when comparing unequal values. */
  public void testDegenerateComparator() throws Exception {
    TreeMultiset<String> ms = TreeMultiset.create(DEGENERATE_COMPARATOR);

    ms.add("foo");
    ms.add("a");
    ms.add("bar");
    ms.add("b");
    ms.add("c");

    assertEquals(2, ms.count("bar"));
    assertEquals(3, ms.count("b"));

    Multiset<String> ms2 = TreeMultiset.create(DEGENERATE_COMPARATOR);

    ms2.add("cat", 2);
    ms2.add("x", 3);

    assertEquals(ms, ms2);
    assertEquals(ms2, ms);

    SortedSet<String> elementSet = ms.elementSet();
    assertEquals("a", elementSet.first());
    assertEquals("foo", elementSet.last());
    assertEquals(DEGENERATE_COMPARATOR, elementSet.comparator());
  }
  /**
   * Returns an {@link Optional} containing the last element in this fluent iterable. If the
   * iterable is empty, {@code Optional.absent()} is returned.
   *
   * @throws NullPointerException if the last element is null; if this is a possibility, use {@link
   *     Iterables#getLast} instead.
   */
  public final Optional<E> last() {
    // Iterables#getLast was inlined here so we don't have to throw/catch a NSEE

    // TODO(kevinb): Support a concurrently modified collection?
    if (iterable instanceof List) {
      List<E> list = (List<E>) iterable;
      if (list.isEmpty()) {
        return Optional.absent();
      }
      return Optional.of(list.get(list.size() - 1));
    }
    Iterator<E> iterator = iterable.iterator();
    if (!iterator.hasNext()) {
      return Optional.absent();
    }

    /*
     * TODO(kevinb): consider whether this "optimization" is worthwhile. Users
     * with SortedSets tend to know they are SortedSets and probably would not
     * call this method.
     */
    if (iterable instanceof SortedSet) {
      SortedSet<E> sortedSet = (SortedSet<E>) iterable;
      return Optional.of(sortedSet.last());
    }

    while (true) {
      E current = iterator.next();
      if (!iterator.hasNext()) {
        return Optional.of(current);
      }
    }
  }
  @Test(enabled = true, dependsOnMethods = "testTemplateMatch")
  public void testCreateTwoNodesWithRunScript() throws Exception {
    try {
      client.destroyNodesMatching(NodePredicates.withTag(tag));
    } catch (HttpResponseException e) {
      // TODO hosting.com throws 400 when we try to delete a vApp
    } catch (NoSuchElementException e) {

    }
    template = buildTemplate(client.templateBuilder());

    template
        .getOptions()
        .installPrivateKey(keyPair.get("private"))
        .authorizePublicKey(keyPair.get("public"))
        .runScript(buildScript(template.getImage().getOsFamily()).getBytes());
    try {
      nodes = Sets.newTreeSet(client.runNodesWithTag(tag, 2, template));
    } catch (RunNodesException e) {
      nodes = Sets.newTreeSet(Iterables.concat(e.getSuccessfulNodes(), e.getNodeErrors().keySet()));
      throw e;
    }
    assertEquals(nodes.size(), 2);
    checkNodes(nodes, tag);
    NodeMetadata node1 = nodes.first();
    NodeMetadata node2 = nodes.last();
    // credentials aren't always the same
    // assertEquals(node1.getCredentials(), node2.getCredentials());

    assertLocationSameOrChild(node1.getLocation(), template.getLocation());
    assertLocationSameOrChild(node2.getLocation(), template.getLocation());

    assertEquals(node1.getImage(), template.getImage());
    assertEquals(node2.getImage(), template.getImage());
  }
 /**
  * Returns the description of the {@code number}. This method distinguishes the case of an invalid
  * prefix and a prefix for which the name is not available in the current language. If the
  * description is not available in the current language an empty string is returned. If no
  * description was found for the provided number, null is returned.
  *
  * @param number the phone number to look up
  * @return the description of the number
  */
 String lookup(long number) {
   int numOfEntries = phonePrefixMapStorage.getNumOfEntries();
   if (numOfEntries == 0) {
     return null;
   }
   long phonePrefix = number;
   int currentIndex = numOfEntries - 1;
   SortedSet<Integer> currentSetOfLengths = phonePrefixMapStorage.getPossibleLengths();
   while (currentSetOfLengths.size() > 0) {
     Integer possibleLength = currentSetOfLengths.last();
     String phonePrefixStr = String.valueOf(phonePrefix);
     if (phonePrefixStr.length() > possibleLength) {
       phonePrefix = Long.parseLong(phonePrefixStr.substring(0, possibleLength));
     }
     currentIndex = binarySearch(0, currentIndex, phonePrefix);
     if (currentIndex < 0) {
       return null;
     }
     int currentPrefix = phonePrefixMapStorage.getPrefix(currentIndex);
     if (phonePrefix == currentPrefix) {
       return phonePrefixMapStorage.getDescription(currentIndex);
     }
     currentSetOfLengths = currentSetOfLengths.headSet(possibleLength);
   }
   return null;
 }
  @Test(enabled = true, dependsOnMethods = "testConcurrentUseOfComputeServiceToCreateNodes")
  public void testCreateTwoNodesWithRunScript() throws Exception {
    try {
      client.destroyNodesMatching(inGroup(group));
    } catch (NoSuchElementException e) {

    }
    refreshTemplate();
    try {
      nodes = newTreeSet(client.createNodesInGroup(group, 2, template));
    } catch (RunNodesException e) {
      nodes = newTreeSet(concat(e.getSuccessfulNodes(), e.getNodeErrors().keySet()));
      throw e;
    }

    assertEquals(nodes.size(), 2, "expected two nodes but was " + nodes);
    checkNodes(nodes, group, "bootstrap");
    NodeMetadata node1 = nodes.first();
    NodeMetadata node2 = nodes.last();
    // credentials aren't always the same
    // assertEquals(node1.getCredentials(), node2.getCredentials());

    assertLocationSameOrChild(
        checkNotNull(node1.getLocation(), "location of %s", node1), template.getLocation());
    assertLocationSameOrChild(
        checkNotNull(node2.getLocation(), "location of %s", node2), template.getLocation());
    checkImageIdMatchesTemplate(node1);
    checkImageIdMatchesTemplate(node2);
    checkOsMatchesTemplate(node1);
    checkOsMatchesTemplate(node2);
  }
  @Test(enabled = true, dependsOnMethods = "testCompareSizes")
  public void testCreateTwoNodesWithRunScript() throws Exception {
    try {
      client.destroyNodesMatching(withTag(tag));
    } catch (NoSuchElementException e) {

    }
    refreshTemplate();
    try {
      nodes = newTreeSet(client.runNodesWithTag(tag, 2, template));
    } catch (RunNodesException e) {
      nodes = newTreeSet(concat(e.getSuccessfulNodes(), e.getNodeErrors().keySet()));
      throw e;
    }
    assertEquals(nodes.size(), 2);
    checkNodes(nodes, tag);
    NodeMetadata node1 = nodes.first();
    NodeMetadata node2 = nodes.last();
    // credentials aren't always the same
    // assertEquals(node1.getCredentials(), node2.getCredentials());

    assertLocationSameOrChild(node1.getLocation(), template.getLocation());
    assertLocationSameOrChild(node2.getLocation(), template.getLocation());
    checkImageIdMatchesTemplate(node1);
    checkImageIdMatchesTemplate(node2);
    checkOsMatchesTemplate(node1);
    checkOsMatchesTemplate(node2);
  }
Example #23
0
  public boolean addAck(int ack) {
    if (ack < 0) throw new IllegalArgumentException("Got negative ack: " + ack);
    if (acks.contains(ack)) return true;
    if (acks.size() >= 255) return false;

    if (acks.size() == 0) {
      length += 3;
    } else if (ack < acks.first()) {
      if ((acks.first() - ack) > 255) return false;
    } else if (ack > acks.last()) {
      if ((ack - acks.last()) > 255) return false;
    }
    acks.add(ack);
    length++;

    return true;
  }
 /**
  * {@inheritDoc}
  *
  * @see java.util.SortedSet#last()
  */
 public E last() {
   lockRead();
   try {
     return m_set.last();
   } finally {
     unlockRead();
   }
 }
Example #25
0
 public int max() {
   if (isEmpty()) {
     return 0;
   }
   SortedSet<Integer> sorted = new TreeSet<Integer>(values());
   Integer val = sorted.last();
   return val.intValue();
 }
  /**
   * runs all the internal checks to verify that the job has been initialized
   *
   * @return true if the job was succesfully initialized
   */
  private boolean runJobNotInitializedChecks() {
    LOGGER.trace("runJobNotInitializedChecks [in]");
    // capture all the start timestamps from the agents
    final SortedSet<Timestamp> lStartTimeStamps = new TreeSet<Timestamp>();

    // check all the control units
    for (ProcessControlUnitWithMonitoring lUnit : mProcessUnits) {

      // obtain status first, if the machine address has been set,
      // it means it was initialized succesfully
      final String lAgentID = lUnit.getAgentId();

      LOGGER.trace("Checking machine address for unit [{}]", lAgentID);
      if (lUnit.getMachineAddress() == null) {
        // one single machine missing means that it hasn't been initialized
        LOGGER.trace("Machine address not found found");
        return false;
      }
      LOGGER.trace("[{}] Machine address found [{}]", lAgentID, lUnit.getMachineAddress());

      // obtain test duration and start time
      final Long lUnitTestDuration = lUnit.getDuration();

      if (mTotalJobDuration == null
          && lUnitTestDuration != null) { // do this only if it hasn't been set before

        LOGGER.trace("[{}] Setting test duration to [{}]", lAgentID, lUnitTestDuration);
        mTotalJobDuration = lUnitTestDuration;
      }

      final Timestamp lUnitStartTimeStamp = lUnit.getStartTimestamp();

      // tree set doesn't handle nulls very well
      if (lUnitStartTimeStamp != null) {
        LOGGER.trace("[{}] Setting initial timestamp [{}]", lAgentID, lUnitStartTimeStamp);
        // add the start timestamp to the set
        lStartTimeStamps.add(lUnitStartTimeStamp);
      } else if (lUnit.getCurrentUserCount() != null && lUnit.getCurrentUserCount() > 0) {

        final Timestamp lInitialTimestamp = new Timestamp(System.currentTimeMillis());

        LOGGER.trace("[{}] Default initial timestamp to [{}]", lAgentID, lInitialTimestamp);
        // if there are already users created,
        // then this means this has already started

        lStartTimeStamps.add(lInitialTimestamp);
      }
    }

    // the biggest, or null if we don't have any start time yet
    mJobStartTime = lStartTimeStamps.isEmpty() ? null : lStartTimeStamps.last();

    mJobInitialized = mJobStartTime != null && mTotalJobDuration != null;

    LOGGER.trace("Job has been initialized [{}]", mJobInitialized);

    return mJobInitialized;
  }
  public boolean isFullyCoveredBy(ColumnFamily cf, long now) {
    // cf will cover all the requested columns if the range it covers include
    // all said columns
    CellName first = cf.iterator(ColumnSlice.ALL_COLUMNS_ARRAY).next().name();
    CellName last = cf.reverseIterator(ColumnSlice.ALL_COLUMNS_ARRAY).next().name();

    return cf.getComparator().compare(first, columns.first()) <= 0
        && cf.getComparator().compare(columns.last(), last) <= 0;
  }
 @Override
 protected Integer detectCurrentVersionNumber() throws IOException {
   SortedSet<CueballFilePath> localBases = Cueball.getBases(localPartitionRoot);
   if (localBases.size() > 0) {
     return localBases.last().getVersion();
   } else {
     return null;
   }
 }
Example #29
0
 @Test
 public void testParseMu() throws Exception {
   SortedSet<MatchResult> results =
       parser.parse(LogFileHelper.getValidCsvLogFile("logWithMu.csv"));
   assertEquals(results.size(), 2);
   assertEquals(results.first().getSkillMean(), 50f);
   assertEquals(results.first().getSkillSigma(), 2.5f);
   assertEquals(results.last().getSkillMean(), 49.9f);
   assertEquals(results.last().getSkillSigma(), 2.49f);
 }
Example #30
0
 public static void verifyOrderedList(SortedSet<Bid> bids) {
   if (bids.size() > 0) {
     double firstPrice = bids.first().getPrice();
     double lastPrice = bids.last().getPrice();
     for (Bid bid : bids) {
       MatcherAssert.assertThat(bid.getPrice(), greaterThanOrEqualTo(firstPrice));
       MatcherAssert.assertThat(bid.getPrice(), lessThanOrEqualTo(lastPrice));
     }
   }
 }