Package com.moesol.geoserver.sync.json

Examples of com.moesol.geoserver.sync.json.Sha1SyncPositionHash


   
//    System.out.println(new Gson().toJson(json));
    assertEquals(0, json.l);
    assertEquals(1, json.h.size());
    assertEquals(257, json.m);
    Sha1SyncPositionHash positionHash = json.h.get(0);
    assertEquals("", positionHash.p);
  }
View Full Code Here


      .hashes(new Sha1SyncPositionHash[0])
      .max(0);
  }

  protected Sha1SyncPositionHash makePosition(String p, String s) {
    return new Sha1SyncPositionHash().position(p).summary(s);
  }
View Full Code Here

    int i = 0; // local index
    int j = 0; // remote index
    int local_size = m_local.h.size();
    int remote_size = m_remote.h == null ? 0 : m_remote.h.size();
    while (i < local_size && j < remote_size) {
      Sha1SyncPositionHash localHashPos = m_local.h.get(i);
      Sha1SyncPositionHash remoteHashPos = m_remote.h.get(j);
     
      int cmp = localHashPos.position().compareTo(remoteHashPos.position());
      if (cmp < 0) {
        remoteMissingPosition(localHashPos.position(), localHashPos);
        i++;
        continue;
      }
      if (cmp > 0) {
        localMissingPosition(remoteHashPos.position(), remoteHashPos);
        j++;
        continue;
      }
     
      // prefix is same on both do hashes match?
      String position = localHashPos.position();
      if (localHashPos.summary().equals(remoteHashPos.summary())) {
        matchAtPosition(position);
      } else {
        differentAtPosition(position, localHashPos, remoteHashPos);
      }
 
      i++;
      j++;
    }
    for ( ; i < local_size; i++) {
      Sha1SyncPositionHash localHashPos = m_local.h.get(i);
      remoteMissingPosition(localHashPos.position(), localHashPos);
    }
    for ( ; j < remote_size; j++) {
      Sha1SyncPositionHash remoteHashPos = m_remote.h.get(j);
      localMissingPosition(remoteHashPos.position(), remoteHashPos);
    }
  }
View Full Code Here

  }

  @Override
  protected void localMissingPosition(String position, Sha1SyncPositionHash missing) {
    // Tell remote side this branch is empty...
    m_result.add(new Sha1SyncPositionHash().position(position));
  }
View Full Code Here

    remote.h.add(makePosition("bb", "1111"));
   
    reconciler.computeOutput(output);
    // Remote thinks it is in sync
    assertEquals(0, output.h.size());
    verify(delete).deleteGroup(new Sha1SyncPositionHash().position("aa").summary("0000"));
  }
View Full Code Here

   
    reconciler.computeOutput(output);
    // Remote thinks it is in sync
    assertEquals(1, output.h.size());
    check(0, "bb", "1110");
    verify(delete).deleteGroup(new Sha1SyncPositionHash().position("aa").summary("0000"));
  }
View Full Code Here

//      }
//  }
 
  public void testFilterDownNextLevel_Level1() {
    Sha1SyncJson local = new Sha1SyncJson().level(0).max(2).hashes(
      new Sha1SyncPositionHash().position("").summary("010101")
    );
    Sha1SyncJson remote = new Sha1SyncJson().level(0).max(2).hashes(
      new Sha1SyncPositionHash().position("").summary("000000")
    );
    Sha1SyncJson output = new Sha1SyncJson().level(2).max(1).hashes(
      new Sha1SyncPositionHash().position("aa").summary("111111"),
      new Sha1SyncPositionHash().position("bb").summary("222222"),
      new Sha1SyncPositionHash().position("cc").summary("333333")
    );
    ServerReconciler r = new ServerReconciler(local, remote);
    r.filterDownNextLevel(output);
    check(output, 0, "aa", "111111");
    check(output, 1, "bb", "222222");
View Full Code Here

    assertEquals(3, output.hashes().size());
  }
 
  public void testFilterDownNextLevel_Level2() {
    Sha1SyncJson local = new Sha1SyncJson().level(1).max(2).hashes(
      new Sha1SyncPositionHash().position("aa").summary("111111"),
      new Sha1SyncPositionHash().position("bb").summary("222222"),
      new Sha1SyncPositionHash().position("cc").summary("333333")
    );
    Sha1SyncJson remote = new Sha1SyncJson().level(1).max(2).hashes(
      new Sha1SyncPositionHash().position("aa").summary(null),
      new Sha1SyncPositionHash().position("bb").summary("212121"),
      new Sha1SyncPositionHash().position("dd").summary("444444")
    );
    Sha1SyncJson output = new Sha1SyncJson().level(2).max(1).hashes(
      new Sha1SyncPositionHash().position("aaaa").summary("aaaaaa"),
      new Sha1SyncPositionHash().position("aabb").summary("aabbbb"),
      new Sha1SyncPositionHash().position("bbbb").summary("bbbbbb"),
      new Sha1SyncPositionHash().position("ccaa").summary("ccaaaa")
    );
    ServerReconciler r = new ServerReconciler(local, remote);
    r.filterDownNextLevel(output);
    check(output, 0, "aaaa", "aaaaaa");
    check(output, 1, "aabb", "aabbbb");
View Full Code Here

    }
    if (remoteSha1Sync.hashes() == null) {
      return LITERAL_TRUE; // Missing all...
    }
   
    Sha1SyncPositionHash sha1Position = new Sha1SyncPositionHash().position(prefixSha1.toString());
    int idx = Collections.binarySearch(remoteSha1Sync.hashes(), sha1Position, POSITION_COMPARATOR);
    if (idx < 0) {
      idx = -idx - 2; // position on shorter prefix
    }
    if (idx < 0 || remoteSha1Sync.hashes().size() < idx) {
      return LITERAL_FALSE;
    }
    Sha1SyncPositionHash remoteGroup = remoteSha1Sync.hashes().get(idx);
    if (!prefixSha1.toString().startsWith(remoteGroup.position())) {
      return LITERAL_FALSE; // Missing position means remote side thinks position is synchronized.
    }
    Sha1Value sha1OfSha1 = m_featureSha1Evaluator.sha1OfSha1(valueSha1);
    if (sha1OfSha1.toString().equals(remoteGroup.summary())) {
      return LITERAL_FALSE; // Exact match, filter
    }
    return LITERAL_TRUE;
  }
View Full Code Here

          +    "</ogc:PropertyIsEqualTo> "
          +   "</ogc:Filter> "
          "</wfs:Query> "
          + "</wfs:GetFeature>";
        Sha1SyncJson client = new Sha1SyncJson().level(0).hashes(
            new Sha1SyncPositionHash().position("").summary("abc123")
        );
        String clientJson = new Gson().toJson(client);
        String xml = String.format(tmpl, clientJson);
//        System.out.println(xml);
       
View Full Code Here

TOP

Related Classes of com.moesol.geoserver.sync.json.Sha1SyncPositionHash

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.