Example usage for org.apache.hadoop.io WritableUtils writeVInt

List of usage examples for org.apache.hadoop.io WritableUtils writeVInt

Introduction

In this page you can find the example usage for org.apache.hadoop.io WritableUtils writeVInt.

Prototype

public static void writeVInt(DataOutput stream, int i) throws IOException 

Source Link

Document

Serializes an integer to a binary stream with zero-compressed encoding.

Usage

From source file:org.apache.hama.bsp.BSPJobClient.java

License:Apache License

private static DataOutputStream writeSplitsFileHeader(Configuration conf, Path filename, int length)
        throws IOException {
    // write the splits to a file for the bsp master
    FileSystem fs = filename.getFileSystem(conf);
    FSDataOutputStream out = FileSystem.create(fs, filename, new FsPermission(JOB_FILE_PERMISSION));
    out.write(SPLIT_FILE_HEADER);//from   w w  w .ja  va 2  s  . c o m
    WritableUtils.writeVInt(out, CURRENT_SPLIT_FILE_VERSION);
    WritableUtils.writeVInt(out, length);
    return out;
}

From source file:org.apache.hama.bsp.DispatchTasksDirective.java

License:Apache License

@Override
public void write(DataOutput out) throws IOException {
    super.write(out);
    if (this.actions == null) {
        WritableUtils.writeVInt(out, 0);
    } else {/*ww w  . j  a  v a2s .  c om*/
        WritableUtils.writeVInt(out, actions.length);
        for (GroomServerAction action : this.actions) {
            WritableUtils.writeEnum(out, action.getActionType());
            action.write(out);
        }
    }
}

From source file:org.apache.hama.bsp.join.CompositeInputSplit.java

License:Apache License

/**
 * Write splits in the following format.
 * {@code//www.  ja v a2  s .  co m
 * <count><class1><class2>...<classn><split1><split2>...<splitn>
 * }
 */
public void write(DataOutput out) throws IOException {
    WritableUtils.writeVInt(out, splits.length);
    for (InputSplit s : splits) {
        Text.writeString(out, s.getClass().getName());
    }
    for (InputSplit s : splits) {
        s.write(out);
    }
}

From source file:org.apache.hama.bsp.TaskCompletionEvent.java

License:Apache License

@Override
public void write(DataOutput out) throws IOException {
    taskId.write(out);/*from   ww w. j  a va2 s  .  co m*/
    WritableUtils.writeVInt(out, idWithinJob);
    WritableUtils.writeEnum(out, status);
    WritableUtils.writeString(out, groomServerInfo);
    WritableUtils.writeVInt(out, taskRunTime);
    WritableUtils.writeVInt(out, eventId);
}

From source file:org.apache.hama.pipes.BinaryProtocol.java

License:Apache License

@Override
public void start() throws IOException {
    LOG.debug("starting downlink");
    WritableUtils.writeVInt(stream, MessageType.START.code);
    WritableUtils.writeVInt(stream, CURRENT_PROTOCOL_VERSION);
    flush();/* ww  w . j  a v a  2 s  . c  o m*/
    LOG.debug("Sent MessageType.START");
    setBSPJob(peer.getConfiguration());
}

From source file:org.apache.hama.pipes.BinaryProtocol.java

License:Apache License

public void setBSPJob(Configuration conf) throws IOException {
    WritableUtils.writeVInt(stream, MessageType.SET_BSPJOB_CONF.code);
    List<String> list = new ArrayList<String>();
    for (Map.Entry<String, String> itm : conf) {
        list.add(itm.getKey());/*from  www . j  a va 2s  .c  o  m*/
        list.add(itm.getValue());
    }
    WritableUtils.writeVInt(stream, list.size());
    for (String entry : list) {
        Text.writeString(stream, entry);
    }
    flush();
    LOG.debug("Sent MessageType.SET_BSPJOB_CONF");
}

From source file:org.apache.hama.pipes.BinaryProtocol.java

License:Apache License

@Override
public void setInputTypes(String keyType, String valueType) throws IOException {
    WritableUtils.writeVInt(stream, MessageType.SET_INPUT_TYPES.code);
    Text.writeString(stream, keyType);
    Text.writeString(stream, valueType);
    flush();/*from  ww  w .  j a  v a  2 s  .c  o  m*/
    LOG.debug("Sent MessageType.SET_INPUT_TYPES");
}

From source file:org.apache.hama.pipes.BinaryProtocol.java

License:Apache License

@Override
public void runSetup(boolean pipedInput, boolean pipedOutput) throws IOException {

    WritableUtils.writeVInt(stream, MessageType.RUN_SETUP.code);
    WritableUtils.writeVInt(stream, pipedInput ? 1 : 0);
    WritableUtils.writeVInt(stream, pipedOutput ? 1 : 0);
    flush();//from  w ww.  j av  a2  s.co  m
    hasTask = true;
    LOG.debug("Sent MessageType.RUN_SETUP");
}

From source file:org.apache.hama.pipes.BinaryProtocol.java

License:Apache License

@Override
public void runBsp(boolean pipedInput, boolean pipedOutput) throws IOException {

    WritableUtils.writeVInt(stream, MessageType.RUN_BSP.code);
    WritableUtils.writeVInt(stream, pipedInput ? 1 : 0);
    WritableUtils.writeVInt(stream, pipedOutput ? 1 : 0);
    flush();//  w  w  w  .j  a v a  2 s. c  o  m
    hasTask = true;
    LOG.debug("Sent MessageType.RUN_BSP");
}

From source file:org.apache.hama.pipes.BinaryProtocol.java

License:Apache License

@Override
public void runCleanup(boolean pipedInput, boolean pipedOutput) throws IOException {

    WritableUtils.writeVInt(stream, MessageType.RUN_CLEANUP.code);
    WritableUtils.writeVInt(stream, pipedInput ? 1 : 0);
    WritableUtils.writeVInt(stream, pipedOutput ? 1 : 0);
    flush();//from   w  w  w  .j  a v a  2 s  . c  om
    hasTask = true;
    LOG.debug("Sent MessageType.RUN_CLEANUP");
}