Tabnine Logo
KeyFactory
Code IndexAdd Tabnine to your IDE (free)

How to use
KeyFactory
in
co.edu.uniquindio.overlay

Best Java code snippets using co.edu.uniquindio.overlay.KeyFactory (Showing top 12 results out of 315)

origin: com.github.estigma88/jdhtuq-chord

ChordKey getKey(String name) {
  return (ChordKey) keyFactory.newKey(name);
}
origin: com.github.estigma88/jdhtuq-chord

/**
 * Constructor of the class. Receives a reference of the chord node and
 * initializes the size, pointer next and the fingers table.
 *
 * @param nodeChord The reference of the chord node.
 */
FingersTable(ChordNode nodeChord, KeyFactory keyFactory) {
  this.size = keyFactory.getKeyLength();
  this.chordNode = nodeChord;
  this.next = 0;
  this.fingersTable = new ChordKey[size];
  this.keyFactory = keyFactory;
}
origin: com.github.estigma88/jdhtuq-dhash

Key getFileKey(String name) {
  return keyFactory.newKey(name);
}
origin: com.github.estigma88/jdhtuq-chord

/**
 * Called always for <code>FingersTable.fixFingers</code>
 * <p>
 * Create the <code>i-th</code> entry to be test in the fingers table. The
 * next entry is given by
 * <code>(node.key + 2^(next-1)) mod 2^(size), 1<=k<=m</code>
 *
 * @param key Node's key
 * @return {@link Key} The key to be test in the fingers table.
 */
ChordKey createNext(ChordKey key) {
  Key nextKey;
  BigInteger nextValue;
  BigInteger twoPow;
  BigInteger maxValue;
  twoPow = new BigInteger("2");
  twoPow = twoPow.pow(next);
  nextValue = new BigInteger(key.getHashing().toByteArray());
  nextValue = nextValue.add(twoPow);
  maxValue = new BigInteger("2");
  maxValue = maxValue.pow(size);
  nextValue = nextValue.mod(maxValue);
  nextKey = keyFactory.newKey(nextValue);
  return (ChordKey) nextKey;
}
origin: com.github.estigma88/jdhtuq-dhash

  @Override
  public void update(Observable observable, Object object) {
    if (object instanceof Message) {
      Message message = (Message) object;

      log.info("Update: " + message);

      if (message.getMessageType().getName().equals(RE_ASSIGN)) {
        try {
          dHashNode.relocateAllResources(keyFactory.newKey(message.getParam(PREDECESSOR)), (name, current, size) -> {
          });
        } catch (StorageException e) {
          log.error("Problem relocating files", e);
        }
      }
    }
  }
}
origin: com.github.estigma88/jdhtuq-chord

/**
 * Process message of type is SET_PREDECESSOR
 *
 * @param message Message SET_PREDECESSOR
 */
private Message processSetPredecessor(Message message) {
  ChordKey nodePredecessor;
  nodePredecessor = (ChordKey) keyFactory.newKey(message
      .getParam(SetPredecessorParams.PREDECESSOR.name()));
  chordNode.setPredecessor(nodePredecessor);
  return null;
}
origin: com.github.estigma88/jdhtuq-chord

/**
 * Process message of type is SET_SUCCESSOR
 *
 * @param message Message SET_SUCCESSOR
 */
private Message processSetSuccessor(Message message) {
  ChordKey nodeSucessor;
  nodeSucessor = (ChordKey) keyFactory.newKey(message.getParam(SetSuccessorParams.SUCCESSOR
      .name()));
  chordNode.setSuccessor(nodeSucessor);
  return null;
}
origin: com.github.estigma88/jdhtuq-chord

/**
 * Process message of type is NOTIFY
 *
 * @param message Message NOTIFY
 */
private Message processNotify(Message message) {
  if (!message.isMessageFromMySelf()) {
    ChordKey node;
    node = (ChordKey) keyFactory.newKey(message.getAddress().getSource());
    chordNode.notify(node);
  }
  return null;
}
origin: com.github.estigma88/jdhtuq-dhash

boolean putSync(Resource resource, ProgressStatus progressStatus) throws StorageException {
  progressStatus.status("put", 0L, 1L);
  progressStatus.status("overlay-node-lookup", 0L, 1L);
  Key key = keyFactory.newKey(resource.getId());
  log.debug("Resource to put: [" + resource.getId() + "] Hashing: ["
      + key.getHashing() + "]");
  Key lookupKey = overlayNode.lookUp(key);
  progressStatus.status("overlay-node-lookup", 1L, 1L);
  if (lookupKey == null) {
    log.error("Impossible to do put the resource: "
        + resource.getId() + " in this moment");
    throw new StorageException("Impossible to do put the resource: "
        + resource.getId() + " in this moment");
  }
  log.debug("Lookup key for " + key.getHashing() + ": ["
      + lookupKey.getValue() + "]");
  boolean success = put(resource, lookupKey, true, progressStatus);
  progressStatus.status("put", 1L, 1L);
  return success;
}
origin: com.github.estigma88/jdhtuq-chord

/**
 * Called periodically in {@link StableRing }.
 * <p>
 * Fixes the successor list by asking node's successor its successor list.
 */
public void fixSuccessors() {
  String successorList;
  ChordKey successor = keyList[0];
  Message getSuccessorListMesssage;
  getSuccessorListMesssage = Message.builder()
      .id(sequenceGenerator.newId())
      .sendType(Message.SendType.REQUEST)
      .messageType(Protocol.GET_SUCCESSOR_LIST)
      .address(Address.builder()
          .destination(successor.getValue())
          .source(chordNode.getKey().getValue())
          .build())
      .build();
  successorList = communicationManager.send(
      getSuccessorListMesssage, String.class);
  if (successorList == null)
    return;
  String[] successors = successorList.split(SEPARATOR);
  for (int i = 1; i < Math.min(size, successors.length); i++) {
    keyList[i] = (ChordKey) keyFactory.newKey(successors[i - 1]);
  }
  log.debug("Node: " + chordNode.getKey().getValue()
      + " Successors: " + toString());
}
origin: com.github.estigma88/jdhtuq-chord

ChordKey id;
id = (ChordKey) keyFactory.newKey(new BigInteger(message.getParam(LookupParams.HASHING
    .name())));
origin: com.github.estigma88/jdhtuq-dhash

Key lookupKey = overlayNode.lookUp(keyFactory.newKey(id));
co.edu.uniquindio.overlayKeyFactory

Javadoc

Factory of keys

Most used methods

  • newKey
    Create a new key with the hashing value
  • getKeyLength
    Key length

Popular in Java

  • Start an intent from android
  • requestLocationUpdates (LocationManager)
  • getSupportFragmentManager (FragmentActivity)
  • setRequestProperty (URLConnection)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Option (scala)
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now