Example usage for io.netty.buffer ByteBuf writeInt

List of usage examples for io.netty.buffer ByteBuf writeInt

Introduction

In this page you can find the example usage for io.netty.buffer ByteBuf writeInt.

Prototype

public abstract ByteBuf writeInt(int value);

Source Link

Document

Sets the specified 32-bit integer at the current writerIndex and increases the writerIndex by 4 in this buffer.

Usage

From source file:com.tesora.dve.mysqlapi.repl.messages.MyCreateFileLogEvent.java

License:Open Source License

@Override
public void marshallMessage(ByteBuf cb) {
    cb.writeInt(threadId);
    cb.writeBytes(variableData);
}

From source file:com.tesora.dve.mysqlapi.repl.messages.MyDeleteFileLogEvent.java

License:Open Source License

@Override
public void marshallMessage(ByteBuf cb) {
    cb.writeInt(fileId);
}

From source file:com.tesora.dve.mysqlapi.repl.messages.MyExecuteLoadLogEvent.java

License:Open Source License

@Override
public void marshallMessage(ByteBuf cb) {
    cb.writeInt(threadId);
    cb.writeInt(time);/*from  w w w. ja  va 2s. c o  m*/
    cb.writeByte(dbLen);
    cb.writeShort(errorCode);
    cb.writeShort(statusBlockLen);
    cb.writeInt(fileId);
    cb.writeInt(startPos);
    cb.writeInt(endPos);
    cb.writeByte(duplicateFlag);

    statusVars.writeStatusVariables(cb);

    cb.writeBytes(dbName.getBytes(CharsetUtil.UTF_8));
    cb.writeByte(0); //for trailing 0
    cb.writeBytes(query);
}

From source file:com.tesora.dve.mysqlapi.repl.messages.MyFormatDescriptionLogEvent.java

License:Open Source License

@Override
public void marshallMessage(ByteBuf cb) {
    cb.writeShort(binaryLogVersion);/*from  w w w  .ja v a 2s.  co m*/
    cb.writeBytes(serverVersion.getBytes(CharsetUtil.UTF_8));
    cb.writeInt((int) createTime);
    cb.writeByte(0xFF & eventTypeLength);
    switch (MyBinLogVerType.fromByte((byte) binaryLogVersion)) {

    case MySQL_5_0:
        for (int i = 1; i <= eventTypeValues.size(); i++) {
            cb.writeByte(eventTypeValues.get(MyLogEventType.fromByte((byte) i)));
        }
        cb.writeZero(1);
        break;

    default:
        break;
    }
}

From source file:com.tesora.dve.mysqlapi.repl.messages.MyLoadLogEvent.java

License:Open Source License

@Override
public void marshallMessage(ByteBuf cb) {
    cb.writeInt(threadId);
    cb.writeInt(time);//from w  w  w .j a v  a2  s  . c om
    cb.writeInt(ignoreLines);
    cb.writeByte(tableLen);
    cb.writeByte(dbLen);
    cb.writeInt(columns);
    cb.writeBytes(variableData);
}

From source file:com.tesora.dve.mysqlapi.repl.messages.MyQueryLogEvent.java

License:Open Source License

@Override
public void marshallMessage(ByteBuf cb) {
    cb.writeInt((int) getSlaveProxyId());
    cb.writeInt((int) getExecTime());
    cb.writeByte(getDbNameLen());// w  w w  . j av  a2 s . com
    cb.writeShort(getErrorCode());
    cb.writeShort(getStatusVarsLen());

    statusVars.writeStatusVariables(cb);

    cb.writeBytes(getDbName().getBytes(CharsetUtil.UTF_8));
    cb.writeByte(0); //for trailing 0
    cb.writeBytes(getQuery());
}

From source file:com.tesora.dve.mysqlapi.repl.messages.MyReplEvent.java

License:Open Source License

@Override
public void marshallMessage(ByteBuf cb) {
    cb.writeInt((int) commonHdr.getTimestamp());
    cb.writeByte(commonHdr.getType());/*from www  .  j  av a 2s .c  om*/
    cb.writeInt((int) commonHdr.getServerId());
    cb.writeInt((int) commonHdr.getTotalSize());
    cb.writeInt((int) commonHdr.getMasterLogPosition());
    cb.writeShort(commonHdr.getFlags());

    if (levp != null) {
        levp.marshallMessage(cb);
    }
}

From source file:com.tesora.dve.mysqlapi.repl.messages.MyStatusVariables.java

License:Open Source License

public void writeStatusVariables(ByteBuf cb) {
    for (BaseQueryEvent qe : getSuppliedEventCodes()) {
        MyQueryEventCode code = qe.getCode();
        switch (code) {
        case Q_FLAGS2_CODE:
            cb.writeByte(code.getByteValue());
            cb.writeInt(((QueryFlags2Event) qe).getFlags());
            break;

        case Q_SQL_MODE_CODE:
            cb.writeByte(code.getByteValue());
            cb.writeLong(((QuerySQLModeEvent) qe).getSqlMode());
            break;

        case Q_CATALOG_CODE:
            cb.writeByte(code.getByteValue());
            cb.writeByte(((QueryCatalogEvent) qe).getCatalog().length());
            cb.writeBytes(((QueryCatalogEvent) qe).getCatalog().getBytes());
            cb.writeByte(0); //for trailing 0
            break;

        case Q_AUTO_INCREMENT:
            cb.writeByte(code.getByteValue());
            cb.writeShort(((QueryAutoIncrementEvent) qe).getAutoIncrementIncrement());
            cb.writeShort(((QueryAutoIncrementEvent) qe).getAutoIncrementOffset());
            break;

        case Q_CHARSET_CODE:
            cb.writeByte(code.getByteValue());
            cb.writeShort(((QueryCharSetCodeEvent) qe).getCharSetClient());
            cb.writeShort(((QueryCharSetCodeEvent) qe).getCollationConnection());
            cb.writeShort(((QueryCharSetCodeEvent) qe).getCollationServer());
            break;

        case Q_TIME_ZONE_CODE:
            cb.writeByte(code.getByteValue());
            cb.writeByte(((QueryTimeZoneCodeEvent) qe).getTimeZone().length());
            cb.writeBytes(((QueryTimeZoneCodeEvent) qe).getTimeZone().getBytes());
            break;

        case Q_CATALOG_NZ_CODE:
            cb.writeByte(code.getByteValue());
            cb.writeByte(((QueryCatalogNZEvent) qe).getCatalog().length());
            cb.writeBytes(((QueryCatalogNZEvent) qe).getCatalog().getBytes());
            break;

        case Q_LC_TIME_NAMES_CODE:
            cb.writeByte(code.getByteValue());
            cb.writeShort(((QueryTimeNamesEvent) qe).getMonthDayNames());
            break;

        case Q_CHARSET_DATABASE_CODE:
            cb.writeByte(code.getByteValue());
            cb.writeShort(((QueryCollationDatabaseEvent) qe).getCollationDatabase());
            break;

        case Q_TABLE_MAP_FOR_UPDATE_CODE:
            cb.writeByte(code.getByteValue());
            cb.writeLong(((QueryTableMapEvent) qe).getTableMapForUpdate());
            break;

        case Q_MASTER_DATA_WRITTEN_CODE:
            cb.writeByte(code.getByteValue());
            cb.writeInt(((QueryMasterDataWrittenEvent) qe).getOriginalLength());
            break;

        case Q_INVOKER:
            cb.writeByte(code.getByteValue());
            cb.writeByte(((QueryInvokerEvent) qe).getUser().length());
            cb.writeBytes(((QueryInvokerEvent) qe).getUser().getBytes());
            cb.writeByte(((QueryInvokerEvent) qe).getHost().length());
            cb.writeBytes(((QueryInvokerEvent) qe).getHost().getBytes());
            break;

        case Q_UPDATED_DB_NAMES:
            cb.writeByte(code.getByteValue());
            List<String> dbs = ((QueryUpdatedDBNamesEvent) qe).getDbNames();
            cb.writeByte(dbs == null ? 0 : dbs.size());
            if (dbs.size() > 0) {
                for (String db : dbs) {
                    cb.writeByte(db.length());
                    cb.writeBytes(db.getBytes(CharsetUtil.UTF_8));
                    cb.writeByte(0); //for trailing 0
                }//from  www .j  ava  2s  . c  om
            }
            break;

        case Q_MICROSECONDS:
            cb.writeByte(code.getByteValue());
            cb.writeMedium(((QueryMicrosecondsEvent) qe).getMicroseconds());
            break;

        case Q_HRNOW:
            cb.writeMedium(((QueryHRNowEvent) qe).threeBytes);
            break;

        default:
            break;
        }
    }
}

From source file:com.tesora.dve.mysqlapi.repl.messages.MyTableMapLogEvent.java

License:Open Source License

@Override
public void marshallMessage(ByteBuf cb) {
    cb.writeInt(tableId);
    cb.writeShort(reserved);
    cb.writeBytes(variableData);
}

From source file:com.tesora.dve.mysqlapi.repl.messages.MyUserVarLogEvent.java

License:Open Source License

@Override
public void marshallMessage(ByteBuf cb) {
    cb.writeInt(variableNameLen);
    cb.writeBytes(variableName.getBytes(CharsetUtil.UTF_8));
    cb.writeByte(nullByte);/*from  w w w .j av a2 s .  co m*/
    if (nullByte != 1) {
        cb.writeByte(valueType.getByteValue());
        cb.writeInt(valueCharSet);
        cb.writeInt(valueLen);
        cb.writeBytes(valueBytes);
    }
}