Example usage for org.apache.commons.lang ArrayUtils EMPTY_BYTE_ARRAY

List of usage examples for org.apache.commons.lang ArrayUtils EMPTY_BYTE_ARRAY

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils EMPTY_BYTE_ARRAY.

Prototype

null EMPTY_BYTE_ARRAY

To view the source code for org.apache.commons.lang ArrayUtils EMPTY_BYTE_ARRAY.

Click Source Link

Document

An empty immutable byte array.

Usage

From source file:com.google.gwt.dev.javac.CompiledClass.java

CompiledClass(TypeDeclaration typeDeclaration, CompiledClass enclosingClass) {
    this.enclosingClass = enclosingClass;
    SourceTypeBinding binding = typeDeclaration.binding;
    this.internalName = CharOperation.charToString(binding.constantPoolName());
    this.isLocal = isLocalType(binding);
    ClassFile classFile = getClassFile(typeDeclaration, internalName);
    if (classFile != null) {
        m_bytes = classFile.getBytes();// w w w .  j  av  a 2s.  c om
    } else {
        m_bytes = ArrayUtils.EMPTY_BYTE_ARRAY;
    }
}

From source file:com.bigdata.dastor.db.RowMutation.java

void addHints(String key) throws IOException {
    QueryPath path = new QueryPath(HintedHandOffManager.HINTS_CF, null, key.getBytes("UTF-8"));
    add(path, ArrayUtils.EMPTY_BYTE_ARRAY, System.currentTimeMillis());
}

From source file:com.facebook.infrastructure.db.RowMutation.java

void addHints(String hint) throws IOException, ColumnFamilyNotDefinedException {
    String cfName = Table.hints_ + ":" + hint;
    add(cfName, ArrayUtils.EMPTY_BYTE_ARRAY, 0);
}

From source file:com.facebook.infrastructure.net.UdpConnection.java

private byte[] gobbleHeaderAndExtractBody(ByteBuffer buffer) {
    byte[] body = ArrayUtils.EMPTY_BYTE_ARRAY;
    byte[] protocol = new byte[4];
    buffer = buffer.get(protocol, 0, protocol.length);
    int value = BasicUtilities.byteArrayToInt(protocol);

    if (protocol_ != value) {
        logger_.info("Invalid protocol header in the incoming message " + value);
        return body;
    }//  ww w.j ava2s .c  o  m
    body = new byte[buffer.remaining()];
    buffer.get(body, 0, body.length);
    return body;
}

From source file:com.facebook.infrastructure.net.io.ContentStreamState.java

public byte[] read() throws IOException, ReadNotCompleteException {
    SocketChannel socketChannel = stream_.getStream();
    InetSocketAddress remoteAddress = (InetSocketAddress) socketChannel.socket().getRemoteSocketAddress();
    String remoteHost = remoteAddress.getHostName();
    createFileChannel();// w  w  w  .  ja  v a2 s  .co  m
    if (streamContext_ != null) {
        try {
            bytesRead_ += fc_.transferFrom(socketChannel, bytesRead_, ContentStreamState.count_);
            if (bytesRead_ != streamContext_.getExpectedBytes())
                throw new ReadNotCompleteException(
                        "Specified number of bytes have not been read from the Socket Channel");
        } catch (IOException ex) {
            /* Ask the source node to re-stream this file. */
            streamStatus_.setAction(StreamContextManager.StreamCompletionAction.STREAM);
            handleStreamCompletion(remoteHost);
            /* Delete the orphaned file. */
            File file = new File(streamContext_.getTargetFile());
            file.delete();
            throw ex;
        }
        if (bytesRead_ == streamContext_.getExpectedBytes()) {
            logger_.debug("Removing stream context " + streamContext_);
            handleStreamCompletion(remoteHost);
            bytesRead_ = 0L;
            fc_.close();
            morphState();
        }
    }

    return ArrayUtils.EMPTY_BYTE_ARRAY;
}

From source file:gobblin.metastore.ZkStateStore.java

@Override
public boolean create(String storeName) throws IOException {
    String path = formPath(storeName);

    return propStore.exists(path, 0)
            || propStore.create(path, ArrayUtils.EMPTY_BYTE_ARRAY, AccessOption.PERSISTENT);
}

From source file:com.palantir.atlasdb.keyvalue.remoting.KeyValueServiceRemotingTest.java

@Test
public void testBytes() throws IOException {
    String serializedEmptyByteArray = mapper.writeValueAsString(new byte[] {});
    byte[] readValue = mapper.readValue(serializedEmptyByteArray, byte[].class);
    Assert.assertArrayEquals(ArrayUtils.EMPTY_BYTE_ARRAY, readValue);
}

From source file:gobblin.metastore.ZkStateStore.java

@Override
public boolean create(String storeName, String tableName) throws IOException {
    String path = formPath(storeName, tableName);

    if (propStore.exists(path, 0)) {
        throw new IOException(
                String.format("State already exists for storeName %s tableName %s", storeName, tableName));
    }//w ww . ja v a2  s.c  o  m

    return propStore.create(path, ArrayUtils.EMPTY_BYTE_ARRAY, AccessOption.PERSISTENT);
}

From source file:com.facebook.infrastructure.db.Row.java

public byte[] digest() {
    long start = System.currentTimeMillis();
    Set<String> cfamilies = columnFamilies_.keySet();
    byte[] xorHash = ArrayUtils.EMPTY_BYTE_ARRAY;
    for (String cFamily : cfamilies) {
        if (xorHash.length == 0) {
            xorHash = columnFamilies_.get(cFamily).digest();
        } else {//from w  w  w.  ja  va  2 s . c o m
            byte[] tmpHash = columnFamilies_.get(cFamily).digest();
            xorHash = FBUtilities.xor(xorHash, tmpHash);
        }
    }
    logger_.info("DIGEST TIME: " + (System.currentTimeMillis() - start) + " ms.");
    return xorHash;
}

From source file:com.bigdata.dastor.dht.BootStrapper.java

private static Token<?> getBootstrapTokenFrom(InetAddress maxEndpoint) {
    Message message = new Message(FBUtilities.getLocalAddress(), "", StorageService.Verb.BOOTSTRAP_TOKEN,
            ArrayUtils.EMPTY_BYTE_ARRAY);
    BootstrapTokenCallback btc = new BootstrapTokenCallback();
    MessagingService.instance.sendRR(message, maxEndpoint, btc);
    return btc.getToken();
}