java.util.concurrent.ConcurrentSkipListMap Java Examples

The following examples show how to use java.util.concurrent.ConcurrentSkipListMap. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CollectionDefaults.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name="setProvider", parallel=true)
public static Iterator<Object[]> setCases() {
    final List<Object[]> cases = new LinkedList<>();
    cases.add(new Object[] { new HashSet<>() });
    cases.add(new Object[] { new LinkedHashSet<>() });
    cases.add(new Object[] { new TreeSet<>() });
    cases.add(new Object[] { new java.util.concurrent.ConcurrentSkipListSet<>() });
    cases.add(new Object[] { new java.util.concurrent.CopyOnWriteArraySet<>() });

    cases.add(new Object[] { new ExtendsAbstractSet<>() });

    cases.add(new Object[] { Collections.newSetFromMap(new HashMap<>()) });
    cases.add(new Object[] { Collections.newSetFromMap(new LinkedHashMap()) });
    cases.add(new Object[] { Collections.newSetFromMap(new TreeMap<>()) });
    cases.add(new Object[] { Collections.newSetFromMap(new ConcurrentHashMap<>()) });
    cases.add(new Object[] { Collections.newSetFromMap(new ConcurrentSkipListMap<>()) });

    cases.add(new Object[] { new HashSet<Integer>(){{add(42);}} });
    cases.add(new Object[] { new ExtendsAbstractSet<Integer>(){{add(42);}} });
    cases.add(new Object[] { new LinkedHashSet<Integer>(){{add(42);}} });
    cases.add(new Object[] { new TreeSet<Integer>(){{add(42);}} });
    return cases.iterator();
}
 
Example #2
Source File: TestChronosController.java    From chronos with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void testGetQueueRunning() throws Exception {
  List<PlannedJob> twoJobs = new ArrayList<>();
  Map<Long, CallableJob> runs =
    new ConcurrentSkipListMap<>();
  Mockito.reset(agentConsumer);
  for (int i = 0; i < 2; i++) {
    JobSpec aJob = getTestJob("bleep bloop");
    aJob.setName("job" + i);
    PlannedJob plannedJob = new PlannedJob(aJob, new DateTime());
    twoJobs.add(plannedJob);
    when(jobDao.getJob(i)).thenReturn(aJob);

    CallableQuery cq =
      new CallableQuery(plannedJob, jobDao, reporting,
                        null, null, null, null, null, 1);
    runs.put(new Long(i), cq);
  }
  when(jobDao.getJobRuns(null, AgentConsumer.LIMIT_JOB_RUNS)).thenReturn(runs);
  mockMvc.perform(get("/api/running"))
    .andExpect(status().isOk())
    .andExpect(content().string(OM.writeValueAsString(twoJobs)));
}
 
Example #3
Source File: BeamWorkerStatusGrpcService.java    From beam with Apache License 2.0 6 votes vote down vote up
/**
 * Get all the statuses from all connected SDK harnesses within specified timeout. Any errors
 * getting status from the SDK harnesses will be returned in the map.
 *
 * @param timeout max time waiting for the response from each SDK harness.
 * @param timeUnit timeout time unit.
 * @return All the statuses in a map keyed by the SDK harness id.
 */
public Map<String, String> getAllWorkerStatuses(long timeout, TimeUnit timeUnit) {
  if (isClosed.get()) {
    throw new IllegalStateException("BeamWorkerStatusGrpcService already closed.");
  }
  // return result in worker id sorted map.
  Map<String, String> allStatuses = new ConcurrentSkipListMap<>(Comparator.naturalOrder());
  Set<String> connectedClientIdsCopy;
  synchronized (connectedClient) {
    connectedClientIdsCopy = ImmutableSet.copyOf(connectedClient.keySet());
  }
  connectedClientIdsCopy
      .parallelStream()
      .forEach(
          workerId ->
              allStatuses.put(workerId, getSingleWorkerStatus(workerId, timeout, timeUnit)));

  return allStatuses;
}
 
Example #4
Source File: ZclScenesCluster.java    From com.zsmartsystems.zigbee with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected Map<Integer, Class<? extends ZclCommand>> initializeClientCommands() {
    Map<Integer, Class<? extends ZclCommand>> commandMap = new ConcurrentSkipListMap<>();

    commandMap.put(0x0000, AddSceneCommand.class);
    commandMap.put(0x0001, ViewSceneCommand.class);
    commandMap.put(0x0002, RemoveSceneCommand.class);
    commandMap.put(0x0003, RemoveAllScenesCommand.class);
    commandMap.put(0x0004, StoreSceneCommand.class);
    commandMap.put(0x0005, RecallSceneCommand.class);
    commandMap.put(0x0006, GetSceneMembershipCommand.class);
    commandMap.put(0x0040, EnhancedAddSceneCommand.class);
    commandMap.put(0x0041, EnhancedViewSceneCommand.class);
    commandMap.put(0x0042, CopySceneCommand.class);

    return commandMap;
}
 
Example #5
Source File: VolatileGeneration.java    From lsmtree with Apache License 2.0 6 votes vote down vote up
public VolatileGeneration(File logPath, Serializer<K> keySerializer, Serializer<V> valueSerializer, Comparator<K> comparator, boolean loadExistingReadOnly) throws IOException {
    this.ordering = Ordering.from(comparator);
    map = new ConcurrentSkipListMap(comparator);
    this.logPath = logPath;
    this.keySerializer = keySerializer;
    this.valueSerializer = valueSerializer;
    deleted = new Object();
    if (loadExistingReadOnly) {
        if (!logPath.exists()) throw new IllegalArgumentException(logPath.getAbsolutePath()+" does not exist");
        transactionLog = null;
        replayTransactionLog(logPath, true);
    } else {
        if (logPath.exists()) throw new IllegalArgumentException("to load existing logs set loadExistingReadOnly to true or create a new log and use replayTransactionLog");
        transactionLog = new TransactionLog.Writer(logPath, keySerializer, valueSerializer, false);
    }
    stuffToClose = SharedReference.create((Closeable)new Closeable() {
        public void close() throws IOException {
            closeWriter();
        }
    });
}
 
Example #6
Source File: ToArray.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void realMain(String[] args) throws Throwable {
    Map<Integer, Long>[] maps = (Map<Integer, Long>[]) new Map[]{
                new HashMap<>(),
                new Hashtable<>(),
                new IdentityHashMap<>(),
                new LinkedHashMap<>(),
                new TreeMap<>(),
                new WeakHashMap<>(),
                new ConcurrentHashMap<>(),
                new ConcurrentSkipListMap<>()
            };

    // for each map type.
    for (Map<Integer, Long> map : maps) {
         try {
            testMap(map);
         } catch(Exception all) {
            unexpected("Failed for " + map.getClass().getName(), all);
         }
    }
}
 
Example #7
Source File: SocketPermission.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
@java.io.Serial
private void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException
{
    // Don't call in.defaultReadObject()

    // Read in serialized fields
    ObjectInputStream.GetField gfields = in.readFields();

    // Get the one we want
    @SuppressWarnings("unchecked")
    Vector<SocketPermission> permissions = (Vector<SocketPermission>)gfields.get("permissions", null);
    perms = new ConcurrentSkipListMap<>(new SPCComparator());
    for (SocketPermission sp : permissions) {
        perms.put(sp.getName(), sp);
    }
}
 
Example #8
Source File: DataAccessImpl.java    From hawkular-metrics with Apache License 2.0 6 votes vote down vote up
private SortedMap<Long, Map<Integer, PreparedStatement>> subSetMap(long startTime, long endTime, Order order) {
    Long startKey = prepMap.floorKey(startTime);
    Long endKey = prepMap.floorKey(endTime);

    // The start time is already compressed, start the request from earliest non-compressed
    if(startKey == null) {
        startKey = prepMap.ceilingKey(startTime);
    }

    // Just in case even the end is in the past
    if(endKey == null) {
        endKey = startKey;
    }

    // Depending on the order, these must be read in the correct order also..
    SortedMap<Long, Map<Integer, PreparedStatement>> statementMap;
    if(order == Order.ASC) {
         statementMap = prepMap.subMap(startKey, true, endKey,
                true);
    } else {
        statementMap = new ConcurrentSkipListMap<>((var0, var2) -> var0 < var2?1:(var0 == var2?0:-1));
        statementMap.putAll(prepMap.subMap(startKey, true, endKey, true));
    }

    return statementMap;
}
 
Example #9
Source File: FifoScheduler.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private synchronized void initScheduler(Configuration conf) {
  validateConf(conf);
  //Use ConcurrentSkipListMap because applications need to be ordered
  this.applications =
      new ConcurrentSkipListMap<ApplicationId, SchedulerApplication<FiCaSchedulerApp>>();
  this.minimumAllocation =
      Resources.createResource(conf.getInt(
          YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB,
          YarnConfiguration.DEFAULT_RM_SCHEDULER_MINIMUM_ALLOCATION_MB));
  initMaximumResourceCapability(
      Resources.createResource(conf.getInt(
          YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_MB,
          YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB),
        conf.getInt(
          YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES,
          YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES),
        conf.getInt(
          YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_GCORES,
          YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_GCORES)));
  this.usePortForNodeName = conf.getBoolean(
      YarnConfiguration.RM_SCHEDULER_INCLUDE_PORT_IN_NODE_NAME,
      YarnConfiguration.DEFAULT_RM_SCHEDULER_USE_PORT_FOR_NODE_NAME);
  this.metrics = QueueMetrics.forQueue(DEFAULT_QUEUE_NAME, null, false,
      conf);
  this.activeUsersManager = new ActiveUsersManager(metrics);
}
 
Example #10
Source File: TabulatorsTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class)
public void testSimpleGroupBy(String name, TestData.OfRef<Integer> data) throws ReflectiveOperationException {
    Function<Integer, Integer> classifier = i -> i % 3;

    // Single-level groupBy
    exerciseMapTabulation(data, groupingBy(classifier),
                          new GroupedMapAssertion<>(classifier, HashMap.class,
                                                    new ListAssertion<>()));
    exerciseMapTabulation(data, groupingByConcurrent(classifier),
                          new GroupedMapAssertion<>(classifier, ConcurrentHashMap.class,
                                                    new ListAssertion<>()));

    // With explicit constructors
    exerciseMapTabulation(data,
                          groupingBy(classifier, TreeMap::new, toCollection(HashSet::new)),
                          new GroupedMapAssertion<>(classifier, TreeMap.class,
                                                    new CollectionAssertion<Integer>(HashSet.class, false)));
    exerciseMapTabulation(data,
                          groupingByConcurrent(classifier, ConcurrentSkipListMap::new,
                                               toCollection(HashSet::new)),
                          new GroupedMapAssertion<>(classifier, ConcurrentSkipListMap.class,
                                                    new CollectionAssertion<Integer>(HashSet.class, false)));
}
 
Example #11
Source File: CollectionDefaults.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name="setProvider", parallel=true)
public static Iterator<Object[]> setCases() {
    final List<Object[]> cases = new LinkedList<>();
    cases.add(new Object[] { new HashSet<>() });
    cases.add(new Object[] { new LinkedHashSet<>() });
    cases.add(new Object[] { new TreeSet<>() });
    cases.add(new Object[] { new java.util.concurrent.ConcurrentSkipListSet<>() });
    cases.add(new Object[] { new java.util.concurrent.CopyOnWriteArraySet<>() });

    cases.add(new Object[] { new ExtendsAbstractSet<>() });

    cases.add(new Object[] { Collections.newSetFromMap(new HashMap<>()) });
    cases.add(new Object[] { Collections.newSetFromMap(new LinkedHashMap<>()) });
    cases.add(new Object[] { Collections.newSetFromMap(new TreeMap<>()) });
    cases.add(new Object[] { Collections.newSetFromMap(new ConcurrentHashMap<>()) });
    cases.add(new Object[] { Collections.newSetFromMap(new ConcurrentSkipListMap<>()) });

    cases.add(new Object[] { new HashSet<Integer>(){{add(42);}} });
    cases.add(new Object[] { new ExtendsAbstractSet<Integer>(){{add(42);}} });
    cases.add(new Object[] { new LinkedHashSet<Integer>(){{add(42);}} });
    cases.add(new Object[] { new TreeSet<Integer>(){{add(42);}} });
    return cases.iterator();
}
 
Example #12
Source File: PersistentIndex.java    From ambry with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the total number of bytes from the beginning of the log to the position of {@code token}. This includes any
 * overhead due to headers and empty space.
 * @param token the point until which the log has been read.
 * @param messageEntries the list of {@link MessageInfo} that were read when producing {@code token}.
 * @param logEndOffsetBeforeFind the end offset of the log before a find was attempted.
 * @param indexSegments the list of index segments to use.
 * @return the total number of bytes read from the log at the position of {@code token}.
 */
private long getTotalBytesRead(StoreFindToken token, List<MessageInfo> messageEntries, Offset logEndOffsetBeforeFind,
    ConcurrentSkipListMap<Offset, IndexSegment> indexSegments) {
  long bytesRead = 0;
  if (token.getType().equals(FindTokenType.IndexBased)) {
    bytesRead = getAbsolutePositionInLogForOffset(token.getOffset(), indexSegments);
  } else if (token.getType().equals(FindTokenType.JournalBased)) {
    if (messageEntries.size() > 0) {
      bytesRead = getAbsolutePositionInLogForOffset(token.getOffset(), indexSegments) + messageEntries.get(
          messageEntries.size() - 1).getSize();
    } else {
      bytesRead = getAbsolutePositionInLogForOffset(logEndOffsetBeforeFind, indexSegments);
    }
  }
  return bytesRead;
}
 
Example #13
Source File: ConcurrentSkipListMapTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * descendingKeySet is ordered
 */
public void testDescendingKeySetOrder() {
    ConcurrentSkipListMap map = map5();
    Set s = map.descendingKeySet();
    Iterator i = s.iterator();
    Integer last = (Integer)i.next();
    assertEquals(last, five);
    int count = 1;
    while (i.hasNext()) {
        Integer k = (Integer)i.next();
        assertTrue(last.compareTo(k) > 0);
        last = k;
        ++count;
    }
    assertEquals(5, count);
}
 
Example #14
Source File: ToArray.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void realMain(String[] args) throws Throwable {
    Map<Integer, Long>[] maps = (Map<Integer, Long>[]) new Map[]{
                new HashMap<>(),
                new Hashtable<>(),
                new IdentityHashMap<>(),
                new LinkedHashMap<>(),
                new TreeMap<>(),
                new WeakHashMap<>(),
                new ConcurrentHashMap<>(),
                new ConcurrentSkipListMap<>()
            };

    // for each map type.
    for (Map<Integer, Long> map : maps) {
         try {
            testMap(map);
         } catch(Exception all) {
            unexpected("Failed for " + map.getClass().getName(), all);
         }
    }
}
 
Example #15
Source File: AbstractGraphPanelVisualizer.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public void switchModel(boolean aggregate) {
    ConcurrentSkipListMap<String, AbstractGraphRow> selectedModel;
    if (aggregate) {
        // issue 64: we must fail requests for aggregate in unsupported cases
        if (modelAggregate.isEmpty() && !model.isEmpty()) {
            throw new UnsupportedOperationException("Seems you've requested "
                    + "aggregate mode for graph that don't support it. We apologize...");
        }

        selectedModel = modelAggregate;
    } else {
        selectedModel = model;
    }

    graphPanel.getGraphObject().setRows(selectedModel);
    graphPanel.clearRowsTab();

    for (AbstractGraphRow abstractGraphRow : selectedModel.values()) {
        graphPanel.addRow(abstractGraphRow);
    }

    isAggregate = aggregate;
    getSettingsPanel().setAggregateMode(aggregate);
}
 
Example #16
Source File: BencodeOutputStreamTest.java    From bencode with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void testWriteDictionary() throws Exception {
    instance.writeDictionary(new LinkedHashMap<Object, Object>() {{
        put("string", "value");
        put("number", 123456);
        put("list", new ArrayList<Object>() {{
            add("list-item-1");
            add("list-item-2");
        }});
        put("dict", new ConcurrentSkipListMap() {{
            put(123, ByteBuffer.wrap("test".getBytes()));
            put(456, "thing");
        }});
    }});

    assertEquals("d6:string5:value6:numberi123456e4:listl11:list-item-111:list-item-2e4:dictd3:1234:test3:4565:thingee",
            new String(out.toByteArray(), instance.getCharset()));
}
 
Example #17
Source File: ZclPressureMeasurementCluster.java    From com.zsmartsystems.zigbee with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected Map<Integer, ZclAttribute> initializeServerAttributes() {
    Map<Integer, ZclAttribute> attributeMap = new ConcurrentSkipListMap<>();

    attributeMap.put(ATTR_MEASUREDVALUE, new ZclAttribute(this, ATTR_MEASUREDVALUE, "Measured Value", ZclDataType.SIGNED_16_BIT_INTEGER, true, true, false, true));
    attributeMap.put(ATTR_MINMEASUREDVALUE, new ZclAttribute(this, ATTR_MINMEASUREDVALUE, "Min Measured Value", ZclDataType.SIGNED_16_BIT_INTEGER, true, true, false, false));
    attributeMap.put(ATTR_MAXMEASUREDVALUE, new ZclAttribute(this, ATTR_MAXMEASUREDVALUE, "Max Measured Value", ZclDataType.SIGNED_16_BIT_INTEGER, true, true, false, true));
    attributeMap.put(ATTR_TOLERANCE, new ZclAttribute(this, ATTR_TOLERANCE, "Tolerance", ZclDataType.UNSIGNED_16_BIT_INTEGER, false, true, false, false));
    attributeMap.put(ATTR_SCALEDVALUE, new ZclAttribute(this, ATTR_SCALEDVALUE, "Scaled Value", ZclDataType.SIGNED_16_BIT_INTEGER, false, true, false, true));
    attributeMap.put(ATTR_MINSCALEDVALUE, new ZclAttribute(this, ATTR_MINSCALEDVALUE, "Min Scaled Value", ZclDataType.SIGNED_16_BIT_INTEGER, false, true, false, false));
    attributeMap.put(ATTR_MAXSCALEDVALUE, new ZclAttribute(this, ATTR_MAXSCALEDVALUE, "Max Scaled Value", ZclDataType.SIGNED_16_BIT_INTEGER, false, true, false, false));
    attributeMap.put(ATTR_SCALEDTOLERANCE, new ZclAttribute(this, ATTR_SCALEDTOLERANCE, "Scaled Tolerance", ZclDataType.UNSIGNED_16_BIT_INTEGER, false, true, false, true));
    attributeMap.put(ATTR_SCALE, new ZclAttribute(this, ATTR_SCALE, "Scale", ZclDataType.UNSIGNED_8_BIT_INTEGER, false, true, false, false));

    return attributeMap;
}
 
Example #18
Source File: ToArray.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void realMain(String[] args) throws Throwable {
    Map<Integer, Long>[] maps = (Map<Integer, Long>[]) new Map[]{
                new HashMap<>(),
                new Hashtable<>(),
                new IdentityHashMap<>(),
                new LinkedHashMap<>(),
                new TreeMap<>(),
                new WeakHashMap<>(),
                new ConcurrentHashMap<>(),
                new ConcurrentSkipListMap<>()
            };

    // for each map type.
    for (Map<Integer, Long> map : maps) {
         try {
            testMap(map);
         } catch(Exception all) {
            unexpected("Failed for " + map.getClass().getName(), all);
         }
    }
}
 
Example #19
Source File: ConcurrentSkipListMapTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * descending iterator of key set is inverse ordered
 */
public void testKeySetDescendingIteratorOrder() {
    ConcurrentSkipListMap map = map5();
    NavigableSet s = map.navigableKeySet();
    Iterator i = s.descendingIterator();
    Integer last = (Integer)i.next();
    assertEquals(last, five);
    int count = 1;
    while (i.hasNext()) {
        Integer k = (Integer)i.next();
        assertTrue(last.compareTo(k) > 0);
        last = k;
        ++count;
    }
    assertEquals(5, count);
}
 
Example #20
Source File: SnapshotStore.java    From qmq with Apache License 2.0 5 votes vote down vote up
public SnapshotStore(final String name, final StorageConfig config, final Serde<T> serde) {
    this.prefix = name + ".";
    this.config = config;
    this.storePath = new File(config.getCheckpointStorePath());
    this.serde = serde;
    this.snapshots = new ConcurrentSkipListMap<>();
    this.cleanerExecutor = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory(name + "-snapshot-cleaner"));

    ensureStorePath();
    loadAllSnapshots();
    scheduleSnapshotCleaner();
}
 
Example #21
Source File: OffHeapList.java    From Oak with Apache License 2.0 5 votes vote down vote up
@Override
public void clear() {

    skipListMap.values().forEach(cell -> {
        allocator.free((ScopedReadBuffer) cell.key.get());
        allocator.free(cell.value.get());
    });
    skipListMap = new ConcurrentSkipListMap<>(comparator);
    allocator.close();
    allocator = new NativeMemoryAllocator((long) Integer.MAX_VALUE * 16);
    System.gc();
}
 
Example #22
Source File: HdfsKeyValueStore.java    From incubator-retired-blur with Apache License 2.0 5 votes vote down vote up
private NavigableMap<BytesRef, Value> createSnapshot() {
  _writeLock.lock();
  try {
    return new ConcurrentSkipListMap<BytesRef, Value>(_pointers);
  } finally {
    _writeLock.unlock();
  }
}
 
Example #23
Source File: ConcurrentSkipListMapTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * entrySet.toArray contains all entries
 */
public void testEntrySetToArray() {
    ConcurrentSkipListMap map = map5();
    Set s = map.entrySet();
    Object[] ar = s.toArray();
    assertEquals(5, ar.length);
    for (int i = 0; i < 5; ++i) {
        assertTrue(map.containsKey(((Map.Entry)(ar[i])).getKey()));
        assertTrue(map.containsValue(((Map.Entry)(ar[i])).getValue()));
    }
}
 
Example #24
Source File: GraphPanelChartTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 *
 */
@Test
public void testPaintComponent_empty() {
    System.out.println("paintComponent_empty");
    Graphics g = new TestGraphics();
    GraphPanelChart instance = new GraphPanelChart();
    instance.setSize(500, 500);
    instance.getChartSettings().setDrawFinalZeroingLines(false);

    final ConcurrentSkipListMap<String, AbstractGraphRow> rows = new ConcurrentSkipListMap<String, AbstractGraphRow>();
    instance.setRows(rows);
    instance.paintComponent(g);
}
 
Example #25
Source File: GraphPanelChartTest.java    From jmeter-plugins with Apache License 2.0 5 votes vote down vote up
/**
 * Test of paintComponent method, of class GraphPanelChart.
 */
@Test
public void testPaintComponent() {
    System.out.println("paintComponent");
    Graphics g = new TestGraphics();
    GraphPanelChart instance = new GraphPanelChart();
    instance.setSize(500, 500);
    instance.getChartSettings().setDrawFinalZeroingLines(true);
    instance.getChartSettings().setDrawCurrentX(true);
    instance.getChartSettings().setExpendRows(true);

    final ConcurrentSkipListMap<String, AbstractGraphRow> rows = new ConcurrentSkipListMap<String, AbstractGraphRow>();
    instance.setRows(rows);
    final GraphRowAverages row1 = new GraphRowAverages();
    row1.setDrawThickLines(true);
    row1.setDrawLine(true);
    row1.setDrawBar(true);
    row1.setDrawValueLabel(true);
    row1.setMarkerSize(AbstractGraphRow.MARKER_SIZE_BIG);
    rows.put("test 1", row1);
    row1.add(System.currentTimeMillis(), 20);

    instance.paintComponent(g);

    row1.add(System.currentTimeMillis(), 540);
    instance.setxAxisLabelRenderer(new DateTimeRenderer("HH:mm:ss"));
    instance.paintComponent(g);

    row1.add(System.currentTimeMillis(), 8530);
    instance.paintComponent(g);
}
 
Example #26
Source File: ZclIasWdCluster.java    From com.zsmartsystems.zigbee with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Map<Integer, Class<? extends ZclCommand>> initializeClientCommands() {
    Map<Integer, Class<? extends ZclCommand>> commandMap = new ConcurrentSkipListMap<>();

    commandMap.put(0x0000, StartWarningCommand.class);
    commandMap.put(0x0001, Squawk.class);

    return commandMap;
}
 
Example #27
Source File: ConcurrentModification.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    test(new ConcurrentHashMap<Integer,Integer>());
    test(new ConcurrentSkipListMap<Integer,Integer>());

    System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
    if (failed > 0) throw new Error("Some tests failed");
}
 
Example #28
Source File: SortedResultMapImpl.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public SortedResultMapImpl(boolean reverse) {
  Comparator comparator = new CachedDeserializableComparator(new NaturalComparator());
  if(reverse) {
    comparator = new ReverseComparator(comparator);
  }
  map = new ConcurrentSkipListMap(comparator);
}
 
Example #29
Source File: SlidingTimeWindowReservoir.java    From light-4j with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new {@link SlidingTimeWindowReservoir} with the given clock and window of time.
 *
 * @param window     the window of time
 * @param windowUnit the unit of {@code window}
 * @param clock      the {@link Clock} to use
 */
public SlidingTimeWindowReservoir(long window, TimeUnit windowUnit, Clock clock) {
    this.clock = clock;
    this.measurements = new ConcurrentSkipListMap<>();
    this.window = windowUnit.toNanos(window) * COLLISION_BUFFER;
    this.lastTick = new AtomicLong(clock.getTick() * COLLISION_BUFFER);
    this.count = new AtomicLong();
}
 
Example #30
Source File: GradeValidationReport.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void addInvalidNumericGrade(String columnTitle, String studentIdentifier, String grade)
{
    SortedMap<String, String> columnInvalidGradesMap = invalidNumericGrades.get(columnTitle);
    if (columnInvalidGradesMap == null)
    {
        columnInvalidGradesMap = new ConcurrentSkipListMap<>();
        columnInvalidGradesMap.put(studentIdentifier, grade);
        invalidNumericGrades.put(columnTitle, columnInvalidGradesMap);
    }
    else
    {
        columnInvalidGradesMap.put(studentIdentifier, grade);
    }
}