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

How to use
BlobKey
in
org.apache.flink.runtime.blob

Best Java code snippets using org.apache.flink.runtime.blob.BlobKey (Showing top 20 results out of 315)

origin: com.alibaba.blink/flink-runtime

BlobKey remoteKey = BlobKey.readFromInputStream(is);
byte[] localHash = md.digest();
if (blobType != remoteKey.getType()) {
  throw new IOException("Detected data corruption during transfer");
if (!Arrays.equals(localHash, remoteKey.getHash())) {
  throw new IOException("Detected data corruption during transfer");
origin: org.apache.flink/flink-runtime_2.10

/**
 * Returns the path for the given blob key.
 *
 * <p>The returned path can be used with the state backend for recovery purposes.
 *
 * <p>This follows the same scheme as {@link #getStorageLocation(File, BlobKey)}
 * and is used for HA.
 */
static String getRecoveryPath(String basePath, BlobKey blobKey) {
  // format: $base/cache/blob_$key
  return String.format("%s/cache/%s%s", basePath, BLOB_FILE_PREFIX, blobKey.toString());
}
origin: org.apache.flink/flink-runtime_2.10

private BlobKey receivePutResponseAndCompare(InputStream is, MessageDigest md) throws IOException {
  int response = is.read();
  if (response < 0) {
    throw new EOFException("Premature end of response");
  }
  else if (response == RETURN_OKAY) {
    if (md == null) {
      // not content addressable
      return null;
    }
    BlobKey remoteKey = BlobKey.readFromInputStream(is);
    BlobKey localKey = new BlobKey(md.digest());
    if (!localKey.equals(remoteKey)) {
      throw new IOException("Detected data corruption during transfer");
    }
    return localKey;
  }
  else if (response == RETURN_ERROR) {
    Throwable cause = readExceptionFromStream(is);
    throw new IOException("Server side error: " + cause.getMessage(), cause);
  }
  else {
    throw new IOException("Unrecognized response: " + response + '.');
  }
}
origin: org.apache.flink/flink-runtime_2.10

@Override
public int read() throws IOException {
  if (this.bytesReceived == this.bytesToReceive) {
    return -1;
  }
  final int read = this.wrappedInputStream.read();
  if (read < 0) {
    throwEOFException();
  }
  ++this.bytesReceived;
  if (this.md != null) {
    this.md.update((byte) read);
    if (this.bytesReceived == this.bytesToReceive) {
      final BlobKey computedKey = new BlobKey(this.md.digest());
      if (!computedKey.equals(this.blobKey)) {
        throw new IOException("Detected data corruption during transfer");
      }
    }
  }
  return read;
}
origin: org.apache.flink/flink-runtime_2.10

blobKey.writeToOutputStream(outputStream);
origin: com.alibaba.blink/flink-runtime

@Override
public int read(byte[] b, int off, int len) throws IOException {
  final int bytesMissing = this.bytesToReceive - this.bytesReceived;
  if (bytesMissing == 0) {
    return -1;
  }
  final int maxRecv = Math.min(len, bytesMissing);
  final int read = this.wrappedInputStream.read(b, off, maxRecv);
  if (read < 0) {
    throwEOFException();
  }
  this.bytesReceived += read;
  if (this.md != null) {
    this.md.update(b, off, read);
    if (this.bytesReceived == this.bytesToReceive) {
      final byte[] computedKey = this.md.digest();
      if (!Arrays.equals(computedKey, this.blobKey.getHash())) {
        this.wrappedOutputStream.write(RETURN_ERROR);
        throw new IOException("Detected data corruption during transfer");
      }
      this.wrappedOutputStream.write(RETURN_OKAY);
    }
  }
  return read;
}
origin: org.apache.flink/flink-runtime

  throw new IOException("Unknown type of BLOB addressing: " + mode + '.');
blobKey = BlobKey.readFromInputStream(inputStream);
origin: org.apache.flink/flink-runtime

return createKey(blobType, key, random);
origin: org.apache.flink/flink-runtime_2.10

BlobKey blobKey = new BlobKey(md.digest());
File storageFile = blobServer.getStorageLocation(blobKey);
blobKey.writeToOutputStream(outputStream);
origin: org.apache.flink/flink-runtime_2.10

/**
 * Auxiliary method to read a BLOB key from an input stream.
 * 
 * @param inputStream
 *        the input stream to read the BLOB key from
 * @return the read BLOB key
 * @throws IOException
 *         throw if an I/O error occurs while reading from the input stream
 */
static BlobKey readFromInputStream(InputStream inputStream) throws IOException {
  final byte[] key = new byte[BlobKey.SIZE];
  int bytesRead = 0;
  while (bytesRead < BlobKey.SIZE) {
    final int read = inputStream.read(key, bytesRead, BlobKey.SIZE - bytesRead);
    if (read < 0) {
      throw new EOFException("Read an incomplete BLOB key");
    }
    bytesRead += read;
  }
  return new BlobKey(key);
}
origin: com.alibaba.blink/flink-runtime

/**
 * Constructs and writes the header data for a GET operation to the given output stream.
 *
 * @param outputStream
 *        the output stream to write the header data to
 * @param jobId
 *         ID of the job this blob belongs to (or <tt>null</tt> if job-unrelated)
 * @param blobKey
 *         blob key associated with the requested file
 *
 * @throws IOException
 *         thrown if an I/O error occurs while writing the header data to the output stream
 */
private static void sendGetHeader(
    OutputStream outputStream, @Nullable JobID jobId, BlobKey blobKey)
    throws IOException {
  checkNotNull(blobKey);
  checkArgument(jobId != null || blobKey instanceof TransientBlobKey,
    "permanent BLOBs must be job-related");
  // Signal type of operation
  outputStream.write(GET_OPERATION);
  // Send job ID and key
  if (jobId == null) {
    outputStream.write(JOB_UNRELATED_CONTENT);
  } else {
    outputStream.write(JOB_RELATED_CONTENT);
    outputStream.write(jobId.getBytes());
  }
  blobKey.writeToOutputStream(outputStream);
}
origin: org.apache.flink/flink-runtime

@Override
public int read() throws IOException {
  if (this.bytesReceived == this.bytesToReceive) {
    return -1;
  }
  final int read = this.wrappedInputStream.read();
  if (read < 0) {
    throwEOFException();
  }
  ++this.bytesReceived;
  if (this.md != null) {
    this.md.update((byte) read);
    if (this.bytesReceived == this.bytesToReceive) {
      final byte[] computedKey = this.md.digest();
      if (!Arrays.equals(computedKey, this.blobKey.getHash())) {
        this.wrappedOutputStream.write(RETURN_ERROR);
        throw new IOException("Detected data corruption during transfer");
      }
      this.wrappedOutputStream.write(RETURN_OKAY);
    }
  }
  return read;
}
origin: org.apache.flink/flink-runtime_2.11

  throw new IOException("Unknown type of BLOB addressing: " + mode + '.');
blobKey = BlobKey.readFromInputStream(inputStream);
origin: com.alibaba.blink/flink-runtime

return createKey(blobType, key, random);
origin: org.apache.flink/flink-runtime_2.10

@Override
public int read(byte[] b, int off, int len) throws IOException {
  final int bytesMissing = this.bytesToReceive - this.bytesReceived;
  if (bytesMissing == 0) {
    return -1;
  }
  final int maxRecv = Math.min(len, bytesMissing);
  final int read = this.wrappedInputStream.read(b, off, maxRecv);
  if (read < 0) {
    throwEOFException();
  }
  this.bytesReceived += read;
  if (this.md != null) {
    this.md.update(b, off, read);
    if (this.bytesReceived == this.bytesToReceive) {
      final BlobKey computedKey = new BlobKey(this.md.digest());
      if (!computedKey.equals(this.blobKey)) {
        throw new IOException("Detected data corruption during transfer");
      }
    }
  }
  return read;
}
origin: org.apache.flink/flink-runtime

BlobKey remoteKey = BlobKey.readFromInputStream(is);
byte[] localHash = md.digest();
if (blobType != remoteKey.getType()) {
  throw new IOException("Detected data corruption during transfer");
if (!Arrays.equals(localHash, remoteKey.getHash())) {
  throw new IOException("Detected data corruption during transfer");
origin: org.apache.flink/flink-runtime

/**
 * Constructs and writes the header data for a GET operation to the given output stream.
 *
 * @param outputStream
 *        the output stream to write the header data to
 * @param jobId
 *         ID of the job this blob belongs to (or <tt>null</tt> if job-unrelated)
 * @param blobKey
 *         blob key associated with the requested file
 *
 * @throws IOException
 *         thrown if an I/O error occurs while writing the header data to the output stream
 */
private static void sendGetHeader(
    OutputStream outputStream, @Nullable JobID jobId, BlobKey blobKey)
    throws IOException {
  checkNotNull(blobKey);
  checkArgument(jobId != null || blobKey instanceof TransientBlobKey,
    "permanent BLOBs must be job-related");
  // Signal type of operation
  outputStream.write(GET_OPERATION);
  // Send job ID and key
  if (jobId == null) {
    outputStream.write(JOB_UNRELATED_CONTENT);
  } else {
    outputStream.write(JOB_RELATED_CONTENT);
    outputStream.write(jobId.getBytes());
  }
  blobKey.writeToOutputStream(outputStream);
}
origin: org.apache.flink/flink-runtime_2.11

@Override
public int read() throws IOException {
  if (this.bytesReceived == this.bytesToReceive) {
    return -1;
  }
  final int read = this.wrappedInputStream.read();
  if (read < 0) {
    throwEOFException();
  }
  ++this.bytesReceived;
  if (this.md != null) {
    this.md.update((byte) read);
    if (this.bytesReceived == this.bytesToReceive) {
      final byte[] computedKey = this.md.digest();
      if (!Arrays.equals(computedKey, this.blobKey.getHash())) {
        this.wrappedOutputStream.write(RETURN_ERROR);
        throw new IOException("Detected data corruption during transfer");
      }
      this.wrappedOutputStream.write(RETURN_OKAY);
    }
  }
  return read;
}
origin: org.apache.flink/flink-runtime_2.10

/**
 * Returns the (designated) physical storage location of the BLOB with the given key.
 *
 * @param key
 *        the key identifying the BLOB
 * @return the (designated) physical storage location of the BLOB
 */
static File getStorageLocation(File storageDir, BlobKey key) {
  return new File(getCacheDirectory(storageDir), BLOB_FILE_PREFIX + key.toString());
}
origin: org.apache.flink/flink-runtime_2.10

blobKey = BlobKey.readFromInputStream(inputStream);
blobFile = blobServer.getStorageLocation(blobKey);
org.apache.flink.runtime.blobBlobKey

Javadoc

A BLOB key uniquely identifies a BLOB.

Most used methods

  • readFromInputStream
    Auxiliary method to read a BLOB key from an input stream.
  • toString
  • writeToOutputStream
    Auxiliary method to write this BLOB key to an output stream.
  • createKey
    Returns the right BlobKey subclass for the given parameters.
  • getHash
    Returns the hash component of this key.
  • getType
    Returns the (internal) BLOB type which is reflected by the inheriting sub-class.
  • <init>
    Constructs a new BLOB key from the given byte array.
  • equals

Popular in Java

  • Start an intent from android
  • requestLocationUpdates (LocationManager)
  • setContentView (Activity)
  • onCreateOptionsMenu (Activity)
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • JPanel (javax.swing)
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Top plugins for WebStorm
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