Exemplo n.º 1
0
  /**
   * Executes a sequence of steps to verify values are in fact stored, retrieved, and removed. The
   * invocations are performed via all different nodes in the system to gain some confidence about
   * the Chord implementation.
   *
   * @throws NodeLeftException
   */
  @Test
  public void testInsert() throws RemoteException, NodeLeftException {
    byte[] test = "hello world".getBytes();

    KeyValueStore kvs = node0.getKeyValueStore();
    kvs.put(test, test);

    kvs = node1.getKeyValueStore();
    Assert.assertArrayEquals(test, (byte[]) kvs.get(test));

    kvs = node2.getKeyValueStore();
    kvs.remove(test);

    kvs = node3.getKeyValueStore();
    Assert.assertNull(kvs.get(test));
  }
Exemplo n.º 2
0
  /**
   * Initializes a complete Chord ring in this virtual machine. Invocations across nodes are
   * in-memory, by-reference invocations.
   */
  @Before
  public void setup() throws RemoteException {
    ScheduledExecutorService ses =
        new ScheduledExecutorService() {

          @Override
          public void execute(Runnable command) {
            // TODO Auto-generated method stub

          }

          @Override
          public <T> Future<T> submit(Runnable task, T result) {
            // TODO Auto-generated method stub
            return null;
          }

          @Override
          public Future<?> submit(Runnable task) {
            // TODO Auto-generated method stub
            return null;
          }

          @Override
          public <T> Future<T> submit(Callable<T> task) {
            // TODO Auto-generated method stub
            return null;
          }

          @Override
          public List<Runnable> shutdownNow() {
            // TODO Auto-generated method stub
            return null;
          }

          @Override
          public void shutdown() {
            // TODO Auto-generated method stub

          }

          @Override
          public boolean isTerminated() {
            // TODO Auto-generated method stub
            return false;
          }

          @Override
          public boolean isShutdown() {
            // TODO Auto-generated method stub
            return false;
          }

          @Override
          public <T> T invokeAny(
              Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
              throws InterruptedException, ExecutionException, TimeoutException {
            // TODO Auto-generated method stub
            return null;
          }

          @Override
          public <T> T invokeAny(Collection<? extends Callable<T>> tasks)
              throws InterruptedException, ExecutionException {
            // TODO Auto-generated method stub
            return null;
          }

          @Override
          public <T> List<Future<T>> invokeAll(
              Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
              throws InterruptedException {
            // TODO Auto-generated method stub
            return null;
          }

          @Override
          public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
              throws InterruptedException {
            // TODO Auto-generated method stub
            return null;
          }

          @Override
          public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
            // TODO Auto-generated method stub
            return false;
          }

          @Override
          public ScheduledFuture<?> scheduleWithFixedDelay(
              Runnable command, long initialDelay, long delay, TimeUnit unit) {
            return null;
          }

          @Override
          public ScheduledFuture<?> scheduleAtFixedRate(
              Runnable command, long initialDelay, long period, TimeUnit unit) {
            // TODO Auto-generated method stub
            return null;
          }

          @Override
          public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
            // TODO Auto-generated method stub
            return null;
          }

          @Override
          public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
            // TODO Auto-generated method stub
            return null;
          }
        };
    node0 = ChordServer.createNode(createConf(0), ses);
    node1 = ChordServer.createNode(createConf(1), ses);
    node2 = ChordServer.createNode(createConf(2), ses);
    node3 = ChordServer.createNode(createConf(3), ses);

    node0.getService().join(null);
    node1.getService().join(node0);
    node2.getService().join(node0);
    node3.getService().join(node0);
  }