Java Code Examples for org.apache.ignite.binary.BinaryWriter#writeInt()

The following examples show how to use org.apache.ignite.binary.BinaryWriter#writeInt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IgniteProducerConfig.java    From joyqueue with Apache License 2.0 6 votes vote down vote up
@Override
public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
    writer.writeString(COLUMN_ID, getId());
    writer.writeString(COLUMN_TOPIC,producer.getTopic().getCode());
    writer.writeString(COLUMN_NAMESPACE, producer.getTopic().getNamespace());
    writer.writeString(COLUMN_APP, producer.getApp());
    if (null != producerPolicy) {
        writer.writeBoolean(COLUMN_NEAR_BY, producerPolicy.getNearby());
        writer.writeBoolean(COLUMN_ARCHIVE, producerPolicy.getArchive());
        writer.writeBoolean(COLUMN_SINGLE, producerPolicy.isSingle());
        if (null != producerPolicy.getBlackList())
            writer.writeString(COLUMN_BLACK_LIST, StringUtils.join(producerPolicy.getBlackList(),","));
        if (null != producerPolicy.getWeight() && producerPolicy.getWeight().size() > 0) {
            StringBuilder stringBuilder = new StringBuilder();
            for (Map.Entry<String, Short> entry : producerPolicy.getWeight().entrySet()) {
                stringBuilder.append(entry.getKey()).append(":").append(entry.getValue()).append(",");
            }
            writer.writeString(COLUMN_WEIGHT, stringBuilder.substring(0, stringBuilder.length() - 1).toString());
        }
    }
    writer.writeInt(COLUMN_TIMEOUT, producerPolicy.getTimeOut());
    if (limitPolicy != null) {
        writer.writeInt(COLUMN_LIMIT_TPS, limitPolicy.getTps());
        writer.writeInt(COLUMN_LIMIT_TRAFFIC, limitPolicy.getTraffic());
    }
}
 
Example 2
Source File: IgniteConsumerConfig.java    From joyqueue with Apache License 2.0 5 votes vote down vote up
@Override
public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
    writer.writeString(COLUMN_ID, getId());
    writer.writeString(COLUMN_TOPIC,  consumer.getTopic().getCode());
    writer.writeString(COLUMN_NAMESPACE,  consumer.getTopic().getNamespace());
    writer.writeString(COLUMN_APP, consumer.getApp());
    if (null != consumerPolicy) {
        writer.writeBoolean(COLUMN_NEAR_BY, consumerPolicy.getNearby());
        writer.writeBoolean(COLUMN_ARCHIVE, consumerPolicy.getArchive());
        writer.writeBoolean(COLUMN_RETRY, consumerPolicy.getRetry());
        writer.writeBoolean(COLUMN_PAUSED,consumerPolicy.getPaused());
        writer.writeInt(COLUMN_ACK_TIMEOUT, consumerPolicy.getAckTimeout());
        writer.writeShort(COLUMN_BATCH_SIZE, consumerPolicy.getBatchSize());
        writer.writeInt(COLUMN_CONCURRENT, consumerPolicy.getConcurrent());
        writer.writeInt(COLUMN_ERROR_TIMES,consumerPolicy.getErrTimes());
        writer.writeInt(COLUMN_MAX_PARTITION_NUM,consumerPolicy.getMaxPartitionNum());
        writer.writeInt(COLUMN_RETRY_READ_PROBABILITY,consumerPolicy.getReadRetryProbability());
        writer.writeMap(COLUMN_FILTERS,consumerPolicy.getFilters());
        if (null != consumerPolicy.getBlackList())
            writer.writeString(COLUMN_BLACK_LIST,StringUtils.join(consumerPolicy.getBlackList(),","));
        writer.writeInt(COLUMN_DELAY, consumerPolicy.getDelay());
    }
    if (null != retryPolicy) {
        writer.writeInt(COLUMN_MAX_RETRYS, retryPolicy.getMaxRetrys());
        writer.writeInt(COLUMN_MAX_RETRY_DELAY, retryPolicy.getMaxRetryDelay());
        writer.writeInt(COLUMN_RETRY_DELAY, retryPolicy.getRetryDelay());
        writer.writeInt(COLUMN_EXPIRE_TIME, retryPolicy.getExpireTime());
    }
    if (limitPolicy != null) {
        writer.writeInt(COLUMN_LIMIT_TPS, limitPolicy.getTps());
        writer.writeInt(COLUMN_LIMIT_TRAFFIC, limitPolicy.getTraffic());
    }
}
 
Example 3
Source File: IgniteBroker.java    From joyqueue with Apache License 2.0 5 votes vote down vote up
@Override
public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
    writer.writeInt(COLUMN_BROKER_ID, id);
    writer.writeString(COLUMN_IP, ip);
    writer.writeInt(COLUMN_PORT, port);
    writer.writeString(COLUMN_DATA_CENTER, dataCenter);
    writer.writeString(COLUMN_RETRY_TYPE, retryType);
    writer.writeString(COLUMN_PERMISSION,permission.getName());
}
 
Example 4
Source File: IgnitePartitionGroup.java    From joyqueue with Apache License 2.0 5 votes vote down vote up
@Override
public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
    writer.writeString(COLUMN_ID, this.getId());
    writer.writeString(COLUMN_NAMESPACE, topic.getNamespace());
    writer.writeString(COLUMN_TOPIC, topic.getCode());
    writer.writeInt(COLUMN_GROUP, this.getGroup());
    if (null != leader) writer.writeInt(COLUMN_LEADER, leader);
    if (null != isrs) writer.writeString(COLUMN_ISR, Arrays.toString(isrs.toArray()));
    if (null != term) writer.writeInt(COLUMN_TERM, term);
    writer.writeString(COLUMN_PARTITIONS, Arrays.toString(partitions.toArray()));
    writer.writeString(COLUMN_REPLICAS, Arrays.toString(replicas.toArray()));
    writer.writeString(COLUMN_ELECT_TYPE, electType.name());
    writer.writeInt(COLUMN_REC_LEADER, recLeader);
}
 
Example 5
Source File: IgniteNodeInfo.java    From vertx-ignite with Apache License 2.0 5 votes vote down vote up
@Override
public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
  writer.writeString("host", nodeInfo.host());
  writer.writeInt("port", nodeInfo.port());
  JsonObject metadata = nodeInfo.metadata();
  writer.writeByteArray("meta", metadata != null ? metadata.toBuffer().getBytes() : null);
}
 
Example 6
Source File: BinaryMarshallerSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
    writer.writeInt("val1", val1);

    if (idx > 0)
        writer.writeInt("val2", val2);

    if (idx > 1)
        writer.writeInt("val3", val3);
}
 
Example 7
Source File: PersonNoIndex.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
    writer.writeInt("id", id);
    writer.writeInt("orgId", orgId);
    writer.writeString("firstName", firstName);
    writer.writeString("lastName", lastName);
    writer.writeDouble("salary", salary);
}
 
Example 8
Source File: Person.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
    writer.writeInt("id", id);
    writer.writeInt("orgId", orgId);
    writer.writeString("firstName", firstName);
    writer.writeString("lastName", lastName);
    writer.writeDouble("salary", salary);
}
 
Example 9
Source File: AbstractBinaryMetadataRegistrationTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
    writer.writeInt("val", val);
}
 
Example 10
Source File: BinaryMarshallerSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeBinary(Object obj, BinaryWriter writer) throws BinaryObjectException {
    CustomSerializedObject2 o = (CustomSerializedObject2)obj;

    writer.writeInt("val", o.val * 3);
}
 
Example 11
Source File: GridCacheBinaryObjectsAbstractSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
    writer.writeInt("val", val);
}
 
Example 12
Source File: BinaryMarshallerSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
    writer.writeByte("_b", b);
    writer.writeShort("_s", s);
    writer.writeInt("_i", i);
    writer.writeLong("_l", l);
    writer.writeFloat("_f", f);
    writer.writeDouble("_d", d);
    writer.writeChar("_c", c);
    writer.writeBoolean("_bool", bool);
    writer.writeString("_str", str);
    writer.writeUuid("_uuid", uuid);
    writer.writeDate("_date", date);
    writer.writeTimestamp("_ts", ts);
    writer.writeTime("_time", time);
    writer.writeByteArray("_bArr", bArr);
    writer.writeShortArray("_sArr", sArr);
    writer.writeIntArray("_iArr", iArr);
    writer.writeLongArray("_lArr", lArr);
    writer.writeFloatArray("_fArr", fArr);
    writer.writeDoubleArray("_dArr", dArr);
    writer.writeCharArray("_cArr", cArr);
    writer.writeBooleanArray("_boolArr", boolArr);
    writer.writeStringArray("_strArr", strArr);
    writer.writeUuidArray("_uuidArr", uuidArr);
    writer.writeDateArray("_dateArr", dateArr);
    writer.writeTimeArray("_timeArr", timeArr);
    writer.writeObjectArray("_objArr", objArr);
    writer.writeCollection("_col", col);
    writer.writeMap("_map", map);
    writer.writeEnum("_enumVal", enumVal);
    writer.writeEnumArray("_enumArr", enumArr);
    writer.writeObject("_simple", simple);
    writer.writeObject("_binary", binary);

    BinaryRawWriter raw = writer.rawWriter();

    raw.writeByte(bRaw);
    raw.writeShort(sRaw);
    raw.writeInt(iRaw);
    raw.writeLong(lRaw);
    raw.writeFloat(fRaw);
    raw.writeDouble(dRaw);
    raw.writeChar(cRaw);
    raw.writeBoolean(boolRaw);
    raw.writeString(strRaw);
    raw.writeUuid(uuidRaw);
    raw.writeDate(dateRaw);
    raw.writeTimestamp(tsRaw);
    raw.writeTime(timeRaw);
    raw.writeByteArray(bArrRaw);
    raw.writeShortArray(sArrRaw);
    raw.writeIntArray(iArrRaw);
    raw.writeLongArray(lArrRaw);
    raw.writeFloatArray(fArrRaw);
    raw.writeDoubleArray(dArrRaw);
    raw.writeCharArray(cArrRaw);
    raw.writeBooleanArray(boolArrRaw);
    raw.writeStringArray(strArrRaw);
    raw.writeUuidArray(uuidArrRaw);
    raw.writeDateArray(dateArrRaw);
    raw.writeTimeArray(timeArrRaw);
    raw.writeObjectArray(objArrRaw);
    raw.writeCollection(colRaw);
    raw.writeMap(mapRaw);
    raw.writeEnum(enumValRaw);
    raw.writeEnumArray(enumArrRaw);
    raw.writeObject(simpleRaw);
    raw.writeObject(binaryRaw);
}
 
Example 13
Source File: AbstractPlatformServiceCallTask.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
    writer.writeInt("id", id);
    writer.writeString("name", name);
}
 
Example 14
Source File: SampleKey.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
    writer.writeInt("id", id);
}
 
Example 15
Source File: GridCacheBinaryObjectsAbstractDataStreamerSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
    writer.writeInt("val", val);
}
 
Example 16
Source File: IntValue.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
    writer.writeInt("id", val);
}
 
Example 17
Source File: GridDataStreamerImplSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
    writer.writeInt("val", val);
}
 
Example 18
Source File: CacheOffheapBatchIndexingBaseTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
    writer.writeInt("id", id);
    writer.writeString("name", name);
}
 
Example 19
Source File: BinaryMarshallerSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
    writer.writeInt("val", val);

    writer.rawWriter().writeInt(rawVal);
}
 
Example 20
Source File: GridCacheBinaryObjectsAbstractMultiThreadedSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
    writer.writeInt("val", val);
}