Example usage for org.apache.hadoop.io Text writeString

List of usage examples for org.apache.hadoop.io Text writeString

Introduction

In this page you can find the example usage for org.apache.hadoop.io Text writeString.

Prototype

public static int writeString(DataOutput out, String s) throws IOException 

Source Link

Document

Write a UTF8 encoded string to out

Usage

From source file:com.chinamobile.bcbsp.pipes.BinaryProtocol.java

License:Apache License

@Override
public void sendKeyValue(String key, String value) throws IOException {
    WritableUtils.writeVInt(outPutstream, MessageType.FLAG_GRAPHDATA.code);
    Text.writeString(outPutstream, key);
    Text.writeString(outPutstream, value);
    this.flush();
    // LOG.info("Run a send graph data command key/value");
}

From source file:com.chinamobile.bcbsp.pipes.BinaryProtocol.java

License:Apache License

@Override
// num = staff num
public void sendKey(String key, int num) throws IOException, InterruptedException {
    WritableUtils.writeVInt(outPutstream, MessageType.COMMAND_PARTITION.code);
    Text.writeString(outPutstream, key);
    WritableUtils.writeVInt(outPutstream, num);
    synchronized (mutex) {
        mutex.wait();//from   w w  w.j  av  a 2s . co  m
    }
}

From source file:com.chinamobile.bcbsp.pipes.BinaryProtocol.java

License:Apache License

@Override
public void sendNewAggregateValue(String[] aggregateValue) throws IOException {
    LOG.info("send new aggregateValue!");
    WritableUtils.writeVInt(outPutstream, MessageType.FLAG_AGGREGATE_VALUE.code);
    for (int i = 0; i < aggregateValue.length; i++) {
        WritableUtils.writeVInt(outPutstream, aggregateValue.length);
        Text.writeString(outPutstream, aggregateValue[i]);
    }//from  ww  w  .  ja va  2s .com
}

From source file:com.chinamobile.bcbsp.sync.SuperStepCommand.java

License:Apache License

@Override
public void write(DataOutput out) throws IOException {
    out.writeInt(this.commandType);
    Text.writeString(out, this.initWritePath);
    Text.writeString(out, this.initReadPath);
    out.writeInt(this.ableCheckPoint);
    out.writeInt(this.nextSuperStepNum);
    out.writeInt(this.oldCheckPoint);
    out.writeInt(this.aggValues.length);
    int count = this.aggValues.length;
    for (int i = 0; i < count; i++) {
        Text.writeString(out, this.aggValues[i]);
    }//  w w  w.j  a  v a  2 s .co m
    if (partitionToWorkerManagerNameAndPort == null) {
        WritableUtils.writeVInt(out, 0);
    } else {
        WritableUtils.writeVInt(out, partitionToWorkerManagerNameAndPort.size());
        String[] partitionToWMName = null;
        for (Integer i : this.partitionToWorkerManagerNameAndPort.keySet()) {
            partitionToWMName[i] = partitionToWorkerManagerNameAndPort.get(i);
        }
        WritableUtils.writeCompressedStringArray(out, partitionToWMName);
    }
    out.writeUTF(this.migrateStaffIDs);
    this.migrateVertexCommand.write(out);
}

From source file:com.chinamobile.bcbsp.sync.SuperStepReportContainer.java

License:Apache License

@Override
public void write(DataOutput out) throws IOException {
    out.writeInt(this.partitionId);
    out.writeInt(this.stageFlag);
    out.writeInt(this.dirFlag.length);
    int count = this.dirFlag.length;
    for (int i = 0; i < count; i++) {
        Text.writeString(out, this.dirFlag[i]);
    }/*from   ww  w  . j  av a  2  s.  c om*/
    out.writeLong(this.judgeFlag);
    out.writeInt(this.localBarrierNum);
    out.writeInt(this.port1);
    out.writeInt(this.port2);
    out.writeInt(this.aggValues.length);
    count = this.aggValues.length;
    for (int i = 0; i < count; i++) {
        Text.writeString(out, this.aggValues[i]);
    }
    out.writeLong(this.staffRunTime);
    out.writeInt(this.sid);
    out.writeInt(this.currentSuperStep);
    out.writeLong(this.migrateCost);
    out.writeFloat(this.splitEdgefactor);
}

From source file:com.chinamobile.bcbsp.util.JobProfile.java

License:Apache License

/** serialize
 * write this object to out./* w w  w .j av  a  2 s .co m*/
 *
 * @param out Writes to the output stream.
 */
@Override
public void write(DataOutput out) throws IOException {
    jobid.write(out);
    Text.writeString(out, jobFile);
    Text.writeString(out, user);
    Text.writeString(out, name);
}

From source file:com.chinamobile.bcbsp.util.JobStatus.java

License:Apache License

/** serialize
 * write this object to out./*from w  w w  .  j a va  2 s  . c o m*/
 *
 * @param out Writes to the output stream.
 */
@Override
public synchronized void write(DataOutput out) throws IOException {
    jobid.write(out);
    out.writeLong(setupProgress);
    out.writeLong(progress);
    out.writeLong(cleanupProgress);
    out.writeInt(runState);
    WritableUtils.writeEnum(out, this.state);
    out.writeLong(startTime);
    out.writeLong(finishTime);
    Text.writeString(out, user);
    //    Text.writeString(out, schedulingInfo);
    out.writeLong(superstepCount);
    out.writeBoolean(recovery);
}

From source file:com.chinamobile.bcbsp.util.StaffStatus.java

License:Apache License

/** serialize
 * write this object to out.//from w  w w  . ja  v a2  s . c  o  m
 *
 * @param out Writes to the output stream.
 */
@Override
public void write(DataOutput out) throws IOException {
    jobId.write(out);
    staffId.write(out);
    out.writeInt(progress);
    WritableUtils.writeEnum(out, runState);
    Text.writeString(out, stateString);
    WritableUtils.writeEnum(out, phase);
    out.writeLong(startTime);
    out.writeLong(finishTime);
    out.writeLong(superstepCount);
    if (this.faultFlag == 0) {
        out.writeInt(this.faultFlag);
    } else {
        out.writeInt(this.faultFlag);
        this.fault.write(out);
    }
    out.writeBoolean(recovery);
    out.writeLong(this.currentSSTime);
    Text.writeString(out, workerManager);
}

From source file:com.chinamobile.bcbsp.workermanager.WorkerManagerStatus.java

License:Apache License

@Override
public void write(DataOutput out) throws IOException {
    Text.writeString(out, this.workerManagerName);
    Text.writeString(out, this.rpc);
    Text.writeString(out, this.host);
    Text.writeString(out, this.httpPort);
    Text.writeString(out, this.localIp);
    out.writeInt(this.staffReports.size());
    for (StaffStatus staffStatus : this.staffReports) {
        staffStatus.write(out);//from w w w .  ja v a2  s. co m
    }
    out.writeInt(this.workerFaultList.size());
    for (Fault faultTemp : this.workerFaultList) {
        faultTemp.write(out);
    }
    out.writeInt(this.maxStaffsCount);
    out.writeInt(this.runningStaffsCount);
    out.writeInt(this.finishedStaffsCount);
    out.writeInt(this.failedStaffsCount);
}

From source file:com.cloudera.crunch.impl.mr.run.CrunchInputSplit.java

License:Apache License

public void write(DataOutput out) throws IOException {
    out.writeInt(nodeIndex);/*  w  w w.  j av a  2 s  . co m*/
    Text.writeString(out, inputFormatClass.getName());
    Text.writeString(out, inputSplit.getClass().getName());
    SerializationFactory factory = new SerializationFactory(conf);
    Serializer serializer = factory.getSerializer(inputSplit.getClass());
    serializer.open((DataOutputStream) out);
    serializer.serialize(inputSplit);
}