Example usage for java.io DataOutput writeBoolean

List of usage examples for java.io DataOutput writeBoolean

Introduction

In this page you can find the example usage for java.io DataOutput writeBoolean.

Prototype

void writeBoolean(boolean v) throws IOException;

Source Link

Document

Writes a boolean value to this output stream.

Usage

From source file:org.apache.hadoop.hbase.security.access.TablePermission.java

@Override
public void write(DataOutput out) throws IOException {
    super.write(out);
    Bytes.writeByteArray(out, table.getName());
    out.writeBoolean(family != null);
    if (family != null) {
        Bytes.writeByteArray(out, family);
    }//from   ww w . j a v  a  2  s.  c o  m
    out.writeBoolean(qualifier != null);
    if (qualifier != null) {
        Bytes.writeByteArray(out, qualifier);
    }
    out.writeBoolean(namespace != null);
    if (namespace != null) {
        Bytes.writeByteArray(out, Bytes.toBytes(namespace));
    }
}

From source file:org.apache.hadoop.hdfs.protocol.LocatedBlocks.java

public void write(DataOutput out) throws IOException {
    out.writeLong(this.fileLength);
    out.writeBoolean(underConstruction);
    // write located blocks
    int nrBlocks = locatedBlockCount();
    out.writeInt(nrBlocks);/*from   w  w  w  .  j  a va2  s .com*/
    if (nrBlocks == 0) {
        return;
    }
    for (LocatedBlock blk : this.blocks) {
        blk.write(out);
    }
}

From source file:org.apache.hadoop.hdfs.server.namenode.FSImageSerialization.java

/**
 * Serialize a {@link INodeFile} node// w  w w .  j av  a 2  s  . c  o m
 * @param node The node to write
 * @param out The {@link DataOutputStream} where the fields are written
 * @param writeBlock Whether to write block information
 */
public static void writeINodeFile(INodeFile file, DataOutput out, boolean writeUnderConstruction)
        throws IOException {
    LOG.info("== Inside writeINodeFile() ==");
    LOG.info("Parameters count and cached logged into FSImage");
    LOG.info("ACCESSCNT " + file.getAccessCount());
    LOG.info("CACHED " + file.getIsCached());
    writeLocalName(file, out);
    out.writeLong(file.getId());
    out.writeShort(file.getFileReplication());
    out.writeLong(file.getModificationTime());
    out.writeLong(file.getAccessTime());
    out.writeLong(file.getPreferredBlockSize());

    writeBlocks(file.getBlocks(), out);
    SnapshotFSImageFormat.saveFileDiffList(file, out);

    if (writeUnderConstruction) {
        if (file instanceof INodeFileUnderConstruction) {
            out.writeBoolean(true);
            final INodeFileUnderConstruction uc = (INodeFileUnderConstruction) file;
            writeString(uc.getClientName(), out);
            writeString(uc.getClientMachine(), out);
        } else {
            out.writeBoolean(false);
        }
    }

    writePermissionStatus(file, out);
    out.writeLong(file.getAccessCount());
    out.writeInt(file.getIsCached());
}

From source file:org.apache.hadoop.hdfs.server.namenode.FSImageSerialization.java

/**
 * Serialize a {@link INodeDirectory}/*w w w .j a  va2  s .  c  om*/
 * @param node The node to write
 * @param out The {@link DataOutput} where the fields are written 
 */
public static void writeINodeDirectory(INodeDirectory node, DataOutput out) throws IOException {
    writeLocalName(node, out);
    out.writeLong(node.getId());
    out.writeShort(0); // replication
    out.writeLong(node.getModificationTime());
    out.writeLong(0); // access time
    out.writeLong(0); // preferred block size
    out.writeInt(-1); // # of blocks

    out.writeLong(node.getNsQuota());
    out.writeLong(node.getDsQuota());
    if (node instanceof INodeDirectorySnapshottable) {
        out.writeBoolean(true);
    } else {
        out.writeBoolean(false);
        out.writeBoolean(node instanceof INodeDirectoryWithSnapshot);
    }

    writePermissionStatus(node, out);
    /*out.writeLong(0);   access count IDecider
    out.writeInt(0);   is cached flag IDecider*/
}

From source file:org.apache.hadoop.hdfs.server.namenode.FSImageSerialization.java

/** Serialize a {@link INodeReference} node */
private static void writeINodeReference(INodeReference ref, DataOutput out, boolean writeUnderConstruction,
        ReferenceMap referenceMap) throws IOException {
    writeLocalName(ref, out);//from   w  ww  . j a  va 2 s  . co  m
    out.writeLong(ref.getId());
    out.writeShort(0); // replication
    out.writeLong(0); // modification time
    out.writeLong(0); // access time
    out.writeLong(0); // preferred block size
    out.writeInt(-3); // # of blocks

    final boolean isWithName = ref instanceof INodeReference.WithName;
    out.writeBoolean(isWithName);

    if (!isWithName) {
        Preconditions.checkState(ref instanceof INodeReference.DstReference);
        // dst snapshot id
        out.writeInt(((INodeReference.DstReference) ref).getDstSnapshotId());
    } else {
        out.writeInt(((INodeReference.WithName) ref).getLastSnapshotId());
    }

    final INodeReference.WithCount withCount = (INodeReference.WithCount) ref.getReferredINode();
    referenceMap.writeINodeReferenceWithCount(withCount, out, writeUnderConstruction);
    out.writeLong(0); // access count IDecider
    out.writeInt(0); // is cached flag IDecider
}

From source file:org.apache.hadoop.hive.accumulo.AccumuloHiveRow.java

@Override
public void write(DataOutput dataOutput) throws IOException {
    if (null != rowId) {
        dataOutput.writeBoolean(true);
        dataOutput.writeUTF(rowId);/* w  w  w. j ava2s.c om*/
    } else {
        dataOutput.writeBoolean(false);
    }
    int size = tuples.size();
    dataOutput.writeInt(size);
    for (ColumnTuple tuple : tuples) {
        Text cf = tuple.getCf(), cq = tuple.getCq();
        dataOutput.writeInt(cf.getLength());
        dataOutput.write(cf.getBytes(), 0, cf.getLength());
        dataOutput.writeInt(cq.getLength());
        dataOutput.write(cq.getBytes(), 0, cq.getLength());
        byte[] value = tuple.getValue();
        dataOutput.writeInt(value.length);
        dataOutput.write(value);
    }
}

From source file:org.apache.hadoop.hive.llap.security.LlapTokenIdentifier.java

@Override
public void write(DataOutput out) throws IOException {
    super.write(out);
    out.writeUTF(clusterId);/*from   w w w. j  av  a 2s . c  o  m*/
    out.writeUTF(appId);
    out.writeBoolean(isSigningRequired);
}

From source file:org.apache.hadoop.ipc.chinamobile.ConnectionHeader.java

@Override
public void write(DataOutput out) throws IOException {
    Text.writeString(out, (protocol == null) ? "" : protocol);
    if (ugi != null) {
        out.writeBoolean(true);
        ugi.write(out);/*  w w  w. j  ava 2  s . c om*/
    } else {
        out.writeBoolean(false);
    }
}

From source file:org.apache.hadoop.ipc.ConnectionHeader.java

@Override
public void write(DataOutput out) throws IOException {
    Text.writeString(out, (protocol == null) ? "" : protocol);
    if (ugi != null) {
        if (authMethod == AuthMethod.KERBEROS) {
            // Send effective user for Kerberos auth
            out.writeBoolean(true);
            out.writeUTF(ugi.getUserName());
            out.writeBoolean(false);//w  ww  . jav  a2 s  .  c om
        } else if (authMethod == AuthMethod.DIGEST) {
            // Don't send user for token auth
            out.writeBoolean(false);
        } else {
            //Send both effective user and real user for simple auth
            out.writeBoolean(true);
            out.writeUTF(ugi.getUserName());
            if (ugi.getRealUser() != null) {
                out.writeBoolean(true);
                out.writeUTF(ugi.getRealUser().getUserName());
            } else {
                out.writeBoolean(false);
            }
        }
    } else {
        out.writeBoolean(false);
    }
}

From source file:org.apache.hadoop.mapred.LaunchTaskAction.java

public void write(DataOutput out) throws IOException {
    out.writeBoolean(task.isMapTask());
    task.write(out);

}