All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.intel.jndn.utils.Client Maven / Gradle / Ivy

Go to download

Collection of tools to simplify synchronous and asynchronous data transfer over the NDN network

There is a newer version: 1.1.1
Show newest version
/*
 * jndn-utils
 * Copyright (c) 2015, Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU Lesser General Public License,
 * version 3, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
 * more details.
 */
package com.intel.jndn.utils;

import java.io.IOException;
import java.util.concurrent.CompletableFuture;
import net.named_data.jndn.Data;
import net.named_data.jndn.Face;
import net.named_data.jndn.Interest;
import net.named_data.jndn.Name;

/**
 * Base functionality provided by all NDN clients in this package.
 *
 * @author Andrew Brown 
 */
public interface Client {

  /**
   * Asynchronously request the Data for an Interest. This will send the
   * Interest and return immediately; with this method, the user is responsible
   * for calling {@link Face#processEvents()} in order for the
   * {@link CompletableFuture} to complete.
   *
   * @param face the {@link Face} on which to make the request; call
   * {@link Face#processEvents()} separately to complete the request
   * @param interest the {@link Interest} to send over the network
   * @return a future {@link Data} packet
   */
  public CompletableFuture getAsync(Face face, Interest interest);

  /**
   * Convenience method for calling
   * {@link #getAsync(net.named_data.jndn.Face, net.named_data.jndn.Interest)}
   * with a default {@link Interest} packet.
   *
   * @param face the {@link Face} on which to make the request; call
   * {@link Face#processEvents()} separately to complete the request
   * @param name the {@link Name} to wrap inside a default {@link Interest}
   * @return a future {@link Data} packet
   */
  public CompletableFuture getAsync(Face face, Name name);

  /**
   * Synchronously retrieve the {@link Data} for an {@link Interest}; this will
   * block until complete (i.e. either the data is received or the interest
   * times out).
   *
   * @param face the {@link Face} on which to make the request; this method will
   * call {@link Face#processEvents()} at a configurable interval until complete
   * or timeout
   * @param interest the {@link Interest} to send over the network
   * @return a {@link Data} packet
   * @throws java.io.IOException if the request fails
   */
  public Data getSync(Face face, Interest interest) throws IOException;
  
  /**
   * Convenience method for calling
   * {@link #getSync(net.named_data.jndn.Face, net.named_data.jndn.Interest)}
   * with a default {@link Interest} packet.
   *
   * @param face the {@link Face} on which to make the request; call
   * {@link Face#processEvents()} separately to complete the request
   * @param name the {@link Name} to wrap inside a default {@link Interest}
   * @return a {@link Data} packet
   * @throws java.io.IOException if the request fails
   */
  public Data getSync(Face face, Name name) throws IOException;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy