Java Code Examples for org.apache.commons.collections.ListUtils#isEqualList()

The following examples show how to use org.apache.commons.collections.ListUtils#isEqualList() . 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: CollectionStringEqualComparator.java    From spring-cloud-gray with Apache License 2.0 6 votes vote down vote up
@Override
    public boolean test(Collection<String> src, Collection<String> another) {
        if (CollectionUtils.isEmpty(src)) {
            return CollectionUtils.isEmpty(another) ? true : false;
        }
        if (CollectionUtils.isEmpty(another)) {
            return false;
        }

        List<String> srcSorted = new ArrayList<>(src);
        Collections.sort(srcSorted);
        List<String> anotherSorted = new ArrayList<>(another);
        Collections.sort(anotherSorted);

//        return CollectionUtils.isEqualCollection();
        return ListUtils.isEqualList(srcSorted, anotherSorted);
    }
 
Example 2
Source File: SiddhiExecutionPlanner.java    From flink-siddhi with Apache License 2.0 6 votes vote down vote up
private void retrievePartition(StreamPartition partition) throws Exception {
    if (partition == null) {
        return;
    }

    if (!streamPartitions.containsKey(partition.getInputStreamId())) {
        streamPartitions.put(partition.getInputStreamId(), partition);
    } else {
        StreamPartition existingPartition = streamPartitions.get(partition.getInputStreamId());
        if (existingPartition.getType().equals(partition.getType())
            && ListUtils.isEqualList(existingPartition.getGroupByList(), partition.getGroupByList())
            || existingPartition.getType().equals(StreamPartition.Type.SHUFFLE) || existingPartition.getType().equals(StreamPartition.Type.PARTITIONWITH)) {
            streamPartitions.put(partition.getInputStreamId(), partition);
        } else {
            throw new Exception("You have incompatible partitions on stream " + partition.getInputStreamId()
                + ": [1] " + streamPartitions.get(partition.getInputStreamId()).toString() + " [2] " + partition.toString() + "");
        }
    }
}
 
Example 3
Source File: PolicyExecutionPlannerImpl.java    From eagle with Apache License 2.0 6 votes vote down vote up
private void retrievePartition(StreamPartition partition) {
    if (partition == null) {
        return;
    }

    if (!effectivePartitions.containsKey(partition.getStreamId())) {
        effectivePartitions.put(partition.getStreamId(), partition);
    } else if (!effectivePartitions.get(partition.getStreamId()).equals(partition)) {
        StreamPartition existingPartition = effectivePartitions.get(partition.getStreamId());
        // If same Type & Columns but different sort spec, then use larger
        if (existingPartition.getType().equals(partition.getType())
            && ListUtils.isEqualList(existingPartition.getColumns(), partition.getColumns())
            && partition.getSortSpec().getWindowPeriodMillis() > existingPartition.getSortSpec().getWindowPeriodMillis()
            || existingPartition.getType().equals(StreamPartition.Type.SHUFFLE)) {
            effectivePartitions.put(partition.getStreamId(), partition);
        } else {
            // Throw exception as it unable to conflict effectivePartitions on same stream will not be able to run in distributed mode
            throw new SiddhiAppValidationException("You have incompatible partitions on stream " + partition.getStreamId()
                + ": [1] " + effectivePartitions.get(partition.getStreamId()).toString() + " [2] " + partition.toString() + "");
        }
    }
}
 
Example 4
Source File: PolicyDefinition.java    From eagle with Apache License 2.0 6 votes vote down vote up
@Override
public boolean equals(Object that) {
    if (that == this) {
        return true;
    }
    if (!(that instanceof Definition)) {
        return false;
    }
    Definition another = (Definition) that;
    if (another.type.equals(this.type)
            && another.value.equals(this.value)
            && ListUtils.isEqualList(another.inputStreams, this.inputStreams)
            && ListUtils.isEqualList(another.outputStreams, this.outputStreams)) {
        return true;
    }
    return false;
}
 
Example 5
Source File: AlertDeduplication.java    From eagle with Apache License 2.0 6 votes vote down vote up
@Override
public boolean equals(Object that) {
    if (that == this) {
        return true;
    }
    if (!(that instanceof AlertDeduplication)) {
        return false;
    }
    AlertDeduplication another = (AlertDeduplication) that;
    if (ListUtils.isEqualList(another.dedupFields, this.dedupFields)
            && Objects.equals(another.dedupIntervalMin, this.dedupIntervalMin)
            && Objects.equals(another.outputStreamId, this.outputStreamId)) {
        return true;
    }
    return false;
}
 
Example 6
Source File: PcapGetterHBaseImplTest.java    From opensoc-streaming with Apache License 2.0 6 votes vote down vote up
/**
 * Test_remove duplicates.
 * 
 * @throws IOException
 *           Signals that an I/O exception has occurred.
 */
@Test
public void test_removeDuplicates() throws IOException {
  PcapGetterHBaseImpl pcapGetter = (PcapGetterHBaseImpl) PcapGetterHBaseImpl
      .getInstance();
  List<String> keys = new ArrayList<String>();

  keys.add("18800006-1800000b-06-0050-5af6");
  keys.add("18800006-1800000b-11-0035-3810");
  keys.add("18800006-1800000b-06-0019-caac");
  keys.add("18800006-1800000b-06-0050-5af6");

  List<String> deDupKeys = pcapGetter.removeDuplicateKeys(keys);
  Assert.isTrue(deDupKeys.size() == 3);
  List<String> testKeys = new ArrayList<String>();
  keys.add("18800006-1800000b-06-0050-5af6");
  keys.add("18800006-1800000b-11-0035-3810");
  keys.add("18800006-1800000b-06-0019-caac");

  ListUtils.isEqualList(deDupKeys, testKeys);
}
 
Example 7
Source File: CollectionStringUnEqualComparator.java    From spring-cloud-gray with Apache License 2.0 5 votes vote down vote up
@Override
public boolean test(Collection<String> src, Collection<String> another) {
    if (CollectionUtils.isEmpty(src)) {
        return CollectionUtils.isEmpty(another) ? false : true;
    }
    if (CollectionUtils.isEmpty(another)) {
        return true;
    }

    return !ListUtils.isEqualList(src, another);
}
 
Example 8
Source File: YarnContainerManager.java    From reef with Apache License 2.0 5 votes vote down vote up
private boolean isSameKindOfRequest(final AMRMClient.ContainerRequest r1, final AMRMClient.ContainerRequest r2) {
  final boolean nodeLabelExpressionIsEqual = r1.getNodeLabelExpression() == r2.getNodeLabelExpression() ||
      (r1.getNodeLabelExpression() != null && r1.getNodeLabelExpression().equals(r2.getNodeLabelExpression()));
  return r1.getPriority().compareTo(r2.getPriority()) == 0
      && r1.getCapability().compareTo(r2.getCapability()) == 0
      && nodeLabelExpressionIsEqual
      && r1.getRelaxLocality() == r2.getRelaxLocality()
      && ListUtils.isEqualList(r1.getNodes(), r2.getNodes())
      && ListUtils.isEqualList(r1.getRacks(), r2.getRacks());
}
 
Example 9
Source File: KafkaMirrorMakerConnector.java    From brooklin with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void run() {
  Datastream datastream = _datastreamGroup.getDatastreams().get(0);
  String bootstrapValue = KafkaConnectionString.valueOf(datastream.getSource().getConnectionString())
      .getBrokers().stream()
      .map(KafkaBrokerAddress::toString)
      .collect(Collectors.joining(KafkaConnectionString.BROKER_LIST_DELIMITER));
  Consumer<?, ?> consumer = createConsumer(_consumerProperties, bootstrapValue,
      _groupIdConstructor.constructGroupId(datastream) + DEST_CONSUMER_GROUP_ID_SUFFIX);

  LOG.info("Fetch thread for {} started", _datastreamGroup.getName());
  while (!isInterrupted() && !_shutdown) {
    try {
      List<String> newPartitionInfo = getPartitionsInfo(consumer);
      LOG.debug("Fetch partition info for {}, oldPartitionInfo: {}, new Partition info: {}"
          , datastream.getName(), _subscribedPartitions, newPartitionInfo);

      if (!ListUtils.isEqualList(newPartitionInfo, _subscribedPartitions)) {
        LOG.info("get updated partition info for {}, oldPartitionInfo: {}, new Partition info: {}"
            , datastream.getName(), _subscribedPartitions, newPartitionInfo);

        _subscribedPartitions = Collections.synchronizedList(newPartitionInfo);
        _initialized = true;
        _partitionChangeCallback.accept(_datastreamGroup);
      }
      Thread.sleep(_partitionFetchIntervalMs);
    } catch (Throwable t) {
      // If the Broker goes down, the consumer will receive an exception. However, there is no need to
      // re-initiate the consumer when the Broker comes back. Kafka consumer will automatic reconnect
      LOG.warn("detect error for thread " + _datastreamGroup.getName() + ", ex: ", t);
      _dynamicMetricsManager.createOrUpdateMeter(MODULE, _datastreamGroup.getName(), NUM_PARTITION_FETCH_ERRORS, 1);
    }
  }

  if (consumer != null) {
    consumer.close();
  }

  consumer = null;
  LOG.info("PartitionDiscoveryThread for {} stopped", _datastreamGroup.getName());
}
 
Example 10
Source File: ListUtilsTest.java    From spring-cloud-gray with Apache License 2.0 3 votes vote down vote up
@Test
public void testIsEqualList() {

    List<String> a = Arrays.asList("a", "b");
    List<String> b = Arrays.asList("b", "a");


    Collections.sort(a);
    Collections.sort(b);

    boolean c = ListUtils.isEqualList(a, b);
    System.out.println(c);
}