Exemplo n.º 1
1
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + (data == null ? 0 : data.hashCode());
   result = prime * result + (exception == null ? 0 : exception.hashCode());
   result = prime * result + (extras == null ? 0 : extras.hashCode());
   return result;
 }
Exemplo n.º 2
0
  protected String getEdgeId(Data d1, Data d2) {
    if (d1.hashCode() > d2.hashCode()) {
      Data t = d1;
      d1 = d2;
      d2 = t;
    }

    return String.format("%s--%s", d1.id, d2.id);
  }
Exemplo n.º 3
0
  @Test
  public void testPartitionHash() {
    PartitioningStrategy partitionStrategy =
        new PartitioningStrategy() {
          @Override
          public Object getPartitionKey(Object key) {
            return key.hashCode();
          }
        };

    SerializationService ss = new DefaultSerializationServiceBuilder().build();

    String obj = String.valueOf(System.nanoTime());
    Data dataWithPartitionHash = ss.toData(obj, partitionStrategy);
    Data dataWithOutPartitionHash = ss.toData(obj);

    assertTrue(dataWithPartitionHash.hasPartitionHash());
    assertNotEquals(dataWithPartitionHash.hashCode(), dataWithPartitionHash.getPartitionHash());

    assertFalse(dataWithOutPartitionHash.hasPartitionHash());
    assertEquals(dataWithOutPartitionHash.hashCode(), dataWithOutPartitionHash.getPartitionHash());
  }
Exemplo n.º 4
0
 public BufferItem(byte[] bytes, long ttl, UUID nodeID) {
   data = new Data(bytes, new Date().getTime());
   hash = new Integer(data.hashCode());
   this.ttl = ttl;
   nodeIDs.add(nodeID);
 }
Exemplo n.º 5
0
 private boolean isDuplicate(Data data) {
   if (data != null && bufferedItems.contains(new Integer(data.hashCode()))) {
     return true;
   }
   return false;
 }