Package org.hive2hive.core.network.data.parameters

Examples of org.hive2hive.core.network.data.parameters.Parameters


      NoPeerConnectionException {
    NetworkManager client = network.get(0);

    // verify the locations map before logout
    FutureGet futureGet = client.getDataManager().getUnblocked(
        new Parameters().setLocationKey(userCredentials.getUserId()).setContentKey(
            H2HConstants.USER_LOCATIONS));
    futureGet.awaitUninterruptibly();
    futureGet.getFutureRequests().awaitUninterruptibly();
    Locations locations = (Locations) futureGet.getData().object();

    Assert.assertEquals(1, locations.getPeerAddresses().size());

    // logout
    IProcessComponent process = ProcessFactory.instance().createLogoutProcess(client);
    UseCaseTestUtil.executeProcess(process);

    // verify the locations map after logout
    FutureGet futureGet2 = client.getDataManager().getUnblocked(
        new Parameters().setLocationKey(userCredentials.getUserId()).setContentKey(
            H2HConstants.USER_LOCATIONS));
    futureGet2.awaitUninterruptibly();
    futureGet2.getFutureRequests().awaitUninterruptibly();
    Locations locations2 = (Locations) futureGet2.getData().object();
View Full Code Here


    // encrypt the chunk
    HybridEncryptedContent encryptedChunk = H2HEncryptionUtil.encryptHybrid(chunk,
        encryptionKeys.getPublic());

    // initialize put
    Parameters parameters = new Parameters().setLocationKey(chunk.getId())
        .setContentKey(H2HConstants.FILE_CHUNK).setProtectionKeys(protectionKeysOld)
        .setData(encryptedChunk);
    // indicate to generate hash
    parameters.setHashFlag(true);
    // put encrypted chunk into network
    getter.getDataManager().putUnblocked(parameters).awaitUninterruptibly();

    // verify put
    Assert.assertNotNull(getter.getDataManager().getUnblocked(parameters).awaitUninterruptibly()
        .getData());

    // initialize a fake process context
    BasePKUpdateContext context = new TestChunkPKUpdateContext(protectionKeysOld, protectionKeysNew,
        chunk, parameters.getHash());
    // create a change protection keys process step
    ChangeProtectionKeysStep step = new ChangeProtectionKeysStep(context, getter.getDataManager());
    // run process, should not fail
    UseCaseTestUtil.executeProcessTillSucceded(step);
View Full Code Here

    PutUserLocationsStep step = new PutUserLocationsStep(context, context, putter.getDataManager());
    UseCaseTestUtil.executeProcess(step);

    // get the locations
    FutureGet future = proxy.getDataManager().getUnblocked(
        new Parameters().setLocationKey(userId).setContentKey(H2HConstants.USER_LOCATIONS));
    future.awaitUninterruptibly();
    Assert.assertNotNull(future.getData());
    Locations found = (Locations) future.getData().object();

    // verify if both objects are the same
View Full Code Here

    // wait for the process to finish
    UseCaseTestUtil.waitTillFailed(listener, 10);

    // get the locations which should be stored at the proxy --> they should be null
    FutureGet futureGet = proxy.getDataManager().getUnblocked(
        new Parameters().setLocationKey(userId).setContentKey(H2HConstants.USER_LOCATIONS));
    futureGet.awaitUninterruptibly();
    assertNull(futureGet.getData());
  }
View Full Code Here

    HybridEncryptedContent encryptedMetaFile = H2HEncryptionUtil.encryptHybrid(metaFileSmall,
        metaFileEncryptionKeys.getPublic());
    encryptedMetaFile.generateVersionKey();

    // initialize put
    Parameters parameters = new Parameters()
        .setLocationKey(H2HEncryptionUtil.key2String(metaFileSmall.getId()))
        .setContentKey(H2HConstants.META_FILE).setVersionKey(encryptedMetaFile.getVersionKey())
        .setProtectionKeys(protectionKeysOld).setData(encryptedMetaFile);
    // indicate to generate hash
    parameters.setHashFlag(true);
    // put encrypted meta file into network
    getter.getDataManager().putUnblocked(parameters).awaitUninterruptibly();

    // verify put
    Assert.assertNotNull(getter.getDataManager().getUnblocked(parameters).awaitUninterruptibly()
        .getData());

    // initialize a fake process context
    BasePKUpdateContext context = new TestMetaFilePKUpdateContext(protectionKeysOld, protectionKeysNew,
        metaFileSmall, parameters.getHash(), encryptedMetaFile.getVersionKey());
    // create a change protection keys process step
    ChangeProtectionKeysStep step = new ChangeProtectionKeysStep(context, getter.getDataManager());
    // run process, should not fail
    UseCaseTestUtil.executeProcessTillSucceded(step);
View Full Code Here

  public void testPut() throws ClassNotFoundException, IOException, NoPeerConnectionException {
    NetworkManager nodeA = network.get(random.nextInt(networkSize));
    NetworkManager nodeB = network.get(random.nextInt(networkSize));

    H2HTestData data = new H2HTestData(NetworkTestUtil.randomString());
    IParameters parameters = new Parameters().setLocationKey(nodeA.getNodeId())
        .setContentKey(NetworkTestUtil.randomString()).setData(data);

    boolean success = nodeB.getDataManager().put(parameters);
    Assert.assertTrue(success);
    FutureGet futureGet = nodeB.getDataManager().getUnblocked(parameters);
View Full Code Here

      if (i > 0) {
        data.setBasedOnKey(content.get(i - 1).getVersionKey());
      }
      content.add(data);

      IParameters parameters = new Parameters().setLocationKey(locationKey).setContentKey(contentKey)
          .setData(data);
      boolean success = nodeB.getDataManager().put(parameters);
      Assert.assertTrue(success);
      FutureGet futureGet = nodeB.getDataManager().getUnblocked(parameters);
      futureGet.awaitUninterruptibly();
View Full Code Here

    nodeB.getConnection().getPeer().getPeerBean().storage(new TestPutFailureStorage());
    nodeC.getConnection().getPeer().getPeerBean().storage(new TestPutFailureStorage());

    H2HTestData data = new H2HTestData(NetworkTestUtil.randomString());
    Parameters parameters = new Parameters().setLocationKey(nodeA.getNodeId())
        .setContentKey(NetworkTestUtil.randomString()).setData(data);

    boolean success = nodeB.getDataManager().put(parameters);
    Assert.assertFalse(success);
    FutureGet futureGet = nodeA.getDataManager().getUnblocked(parameters);
View Full Code Here

    NetworkManager nodeB = network.get(1);

    nodeB.getConnection().getPeer().getPeerBean().storage(new TestPutFailureStorage());

    H2HTestData data = new H2HTestData(NetworkTestUtil.randomString());
    Parameters parameters = new Parameters().setLocationKey(nodeA.getNodeId())
        .setContentKey(NetworkTestUtil.randomString()).setData(data);

    boolean success = nodeB.getDataManager().put(parameters);
    Assert.assertTrue(success);
    FutureGet futureGet = nodeB.getDataManager().getUnblocked(parameters);
View Full Code Here

    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();
View Full Code Here

TOP

Related Classes of org.hive2hive.core.network.data.parameters.Parameters

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.