Package org.hive2hive.core.network

Examples of org.hive2hive.core.network.NetworkManager


   * @throws ProcessExecutionException
   */
  @Test
  public void testNotifyOwnUserSession() throws ClassNotFoundException, IOException, NoSessionException,
      InvalidProcessStateException, IllegalArgumentException, NoPeerConnectionException {
    NetworkManager notifier = network.get(0);
    // send notification to own peers
    Set<String> users = new HashSet<String>(1);
    users.add(userACredentials.getUserId());
    CountingNotificationMessageFactory msgFactory = new CountingNotificationMessageFactory(notifier);
    IProcessComponent process = ProcessFactory.instance().createNotificationProcess(msgFactory, users,
View Full Code Here


   */
  @Test
  public void testNotifyOtherUsers() throws ClassNotFoundException, IOException,
      InvalidProcessStateException, IllegalArgumentException, NoPeerConnectionException,
      NoSessionException {
    NetworkManager notifier = network.get(0);
    // send notification to own peers
    Set<String> users = new HashSet<String>(3);
    users.add(userACredentials.getUserId());
    users.add(userBCredentials.getUserId());
    users.add(userCCredentials.getUserId());
View Full Code Here

   */
  @Test
  public void testNotifyUnfriendlyLogoutInitial() throws ClassNotFoundException, IOException,
      InterruptedException, InvalidProcessStateException, IllegalArgumentException,
      NoPeerConnectionException, NoSessionException {
    NetworkManager notifier = network.get(0);

    // send notification to own peers
    Set<String> users = new HashSet<String>(2);
    users.add(userACredentials.getUserId());
    users.add(userBCredentials.getUserId());
View Full Code Here

   */
  @Test
  public void testNotifyUnfriendlyLogoutAllPeers() throws ClassNotFoundException, IOException,
      InterruptedException, InvalidProcessStateException, IllegalArgumentException,
      NoPeerConnectionException, NoSessionException {
    NetworkManager notifier = network.get(0);

    // send notification to own peers
    Set<String> users = new HashSet<String>(2);
    users.add(userACredentials.getUserId());
    users.add(userBCredentials.getUserId());
View Full Code Here

   */
  @Test
  public void testNotifyUnfriendlyLogoutOwnPeer() throws ClassNotFoundException, IOException,
      InterruptedException, InvalidProcessStateException, IllegalArgumentException,
      NoPeerConnectionException, NoSessionException {
    NetworkManager notifier = network.get(0);

    // send notification to own peers
    Set<String> users = new HashSet<String>(1);
    users.add(userACredentials.getUserId());
    CountingNotificationMessageFactory msgFactory = new CountingNotificationMessageFactory(notifier);
View Full Code Here

  }

  @Test
  public void getFileListTest() throws IOException, IllegalFileLocation, InvalidProcessStateException,
      NoPeerConnectionException, NoSessionException {
    NetworkManager client = network.get(0);
    List<FileTaste> fileList = UseCaseTestUtil.getFileList(client);

    // root does not count as a file
    assertEquals(0, fileList.size());
View Full Code Here

  }

  @Test
  public void testPutVersionConflictWin() throws ClassNotFoundException, IOException,
      NoPeerConnectionException {
    NetworkManager nodeA = network.get(0);
    NetworkManager nodeB = network.get(1);

    String locationKey = nodeA.getNodeId();
    String contentKey = "content key";
    H2HTestData data1 = new H2HTestData("data1");
    data1.generateVersionKey();
    waitATick();
    H2HTestData data2A = new H2HTestData("data2A");
    data2A.generateVersionKey();
    data2A.setBasedOnKey(data1.getVersionKey());
    waitATick();
    H2HTestData data2B = new H2HTestData("data2B");
    data2B.generateVersionKey();
    data2B.setBasedOnKey(data1.getVersionKey());

    Parameters parameters1 = new Parameters().setLocationKey(locationKey).setContentKey(contentKey)
        .setVersionKey(data1.getVersionKey()).setData(data1);
    Parameters parameters2A = new Parameters().setLocationKey(locationKey).setContentKey(contentKey)
        .setVersionKey(data2A.getVersionKey()).setData(data2A);
    Parameters parameters2B = new Parameters().setLocationKey(locationKey).setContentKey(contentKey)
        .setVersionKey(data2B.getVersionKey()).setData(data2B);

    nodeB.getDataManager().putUnblocked(parameters1).awaitUninterruptibly();
    nodeB.getDataManager().putUnblocked(parameters2A).awaitUninterruptibly();

    boolean success = nodeB.getDataManager().put(parameters2B);
    Assert.assertFalse(success);

    FutureGet futureGet2A = nodeB.getDataManager().getUnblocked(parameters2A);
    futureGet2A.awaitUninterruptibly();
    assertEquals(data2A.getTestString(), ((H2HTestData) futureGet2A.getData().object()).getTestString());

    FutureGet futureGet2B = nodeA.getDataManager().getVersionUnblocked(parameters2B);
    futureGet2B.awaitUninterruptibly();
View Full Code Here

  public void testPutGet() throws Exception {
    String data = NetworkTestUtil.randomString();
    Parameters parameters = new Parameters().setLocationKey(NetworkTestUtil.randomString())
        .setContentKey(NetworkTestUtil.randomString()).setData(new H2HTestData(data));

    NetworkManager node = network.get(random.nextInt(networkSize));

    FuturePut future = node.getDataManager().putUnblocked(parameters);
    future.awaitUninterruptibly();

    FutureGet futureGet = node.getDataManager().getUnblocked(parameters);
    futureGet.awaitUninterruptibly();

    String result = (String) ((H2HTestData) futureGet.getData().object()).getTestString();
    assertEquals(data, result);
  }
View Full Code Here

  public void testPutGetFromOtherNode() throws Exception {
    String data = NetworkTestUtil.randomString();
    Parameters parameters = new Parameters().setLocationKey(NetworkTestUtil.randomString())
        .setContentKey(NetworkTestUtil.randomString()).setData(new H2HTestData(data));

    NetworkManager nodeA = network.get(random.nextInt(networkSize / 2));
    NetworkManager nodeB = network.get(random.nextInt(networkSize / 2) + networkSize / 2);

    FuturePut future = nodeA.getDataManager().putUnblocked(parameters);
    future.awaitUninterruptibly();

    FutureGet futureGet = nodeB.getDataManager().getUnblocked(parameters);
    futureGet.awaitUninterruptibly();

    String result = ((H2HTestData) futureGet.getData().object()).getTestString();
    assertEquals(data, result);
  }
View Full Code Here

  @Test
  public void testPutOneLocationKeyMultipleContentKeys() throws Exception {
    String locationKey = NetworkTestUtil.randomString();

    NetworkManager node = network.get(random.nextInt(networkSize));

    String data1 = NetworkTestUtil.randomString();
    Parameters parameters1 = new Parameters().setLocationKey(locationKey)
        .setContentKey(NetworkTestUtil.randomString()).setData(new H2HTestData(data1));
    FuturePut future1 = node.getDataManager().putUnblocked(parameters1);
    future1.awaitUninterruptibly();

    String data2 = NetworkTestUtil.randomString();
    Parameters parameters2 = new Parameters().setLocationKey(locationKey)
        .setContentKey(NetworkTestUtil.randomString()).setData(new H2HTestData(data2));
    FuturePut future2 = node.getDataManager().putUnblocked(parameters2);
    future2.awaitUninterruptibly();

    String data3 = NetworkTestUtil.randomString();
    Parameters parameters3 = new Parameters().setLocationKey(locationKey)
        .setContentKey(NetworkTestUtil.randomString()).setData(new H2HTestData(data3));
    FuturePut future3 = node.getDataManager().putUnblocked(parameters3);
    future3.awaitUninterruptibly();

    FutureGet get1 = node.getDataManager().getUnblocked(parameters1);
    get1.awaitUninterruptibly();
    String result1 = (String) ((H2HTestData) get1.getData().object()).getTestString();
    assertEquals(data1, result1);

    FutureGet get2 = node.getDataManager().getUnblocked(parameters2);
    get2.awaitUninterruptibly();
    String result2 = (String) ((H2HTestData) get2.getData().object()).getTestString();
    assertEquals(data2, result2);

    FutureGet get3 = node.getDataManager().getUnblocked(parameters3);
    get3.awaitUninterruptibly();
    String result3 = (String) ((H2HTestData) get3.getData().object()).getTestString();
    assertEquals(data3, result3);
  }
View Full Code Here

TOP

Related Classes of org.hive2hive.core.network.NetworkManager

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.