List of usage examples for io.netty.buffer ByteBuf writeBytes
public abstract ByteBuf writeBytes(ByteBuffer src);
From source file:com.tesora.dve.mysqlapi.repl.messages.MyExecuteLoadLogEvent.java
License:Open Source License
@Override public void marshallMessage(ByteBuf cb) { cb.writeInt(threadId);// w w w .j a va2 s .c o m cb.writeInt(time); 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. j a va 2s.c o 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);/*from w w w . ja v a 2s. com*/ cb.writeInt(time); 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());/*from ww w .j a v a 2 s . co m*/ 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.MyRotateLogEvent.java
License:Open Source License
@Override public void marshallMessage(ByteBuf cb) { cb.writeLong(position); cb.writeBytes(newLogFileName.getBytes(CharsetUtil.UTF_8)); }
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 w ww . j a v a 2 s. 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);/*from ww w . j av a2 s .c o m*/ cb.writeBytes(variableName.getBytes(CharsetUtil.UTF_8)); cb.writeByte(nullByte); if (nullByte != 1) { cb.writeByte(valueType.getByteValue()); cb.writeInt(valueCharSet); cb.writeInt(valueLen); cb.writeBytes(valueBytes); } }
From source file:com.theoriginalbit.moarperipherals.common.network.message.MessageGeneric.java
License:Apache License
@Override public void toBytes(ByteBuf buf) { // Write any string data if (stringData != null) { buf.writeInt(stringData.length); for (String str : stringData) { ByteBufUtils.writeUTF8String(buf, str); }/* w w w. j av a 2s .c om*/ } else { buf.writeInt(0); } // Write any integer data if (intData != null) { buf.writeInt(intData.length); for (int i : intData) { buf.writeInt(i); } } else { buf.writeInt(0); } // Write any byte data if (byteData != null) { buf.writeInt(byteData.length); buf.writeBytes(byteData); } else { buf.writeInt(0); } // Write any char data if (charData != null) { buf.writeInt(charData.length); for (char c : charData) { buf.writeChar(c); } } else { buf.writeInt(0); } // Write any float data if (floatData != null) { buf.writeInt(floatData.length); for (float f : floatData) { buf.writeFloat(f); } } else { buf.writeInt(0); } // Write any double data if (doubleData != null) { buf.writeInt(doubleData.length); for (double d : doubleData) { buf.writeDouble(d); } } else { buf.writeInt(0); } // Write any NBT data if (nbtData != null) { buf.writeBoolean(true); ByteBufUtils.writeTag(buf, nbtData); } else { buf.writeBoolean(false); } }
From source file:com.tongbanjie.tarzan.rpc.protocol.NettyEncoder.java
License:Apache License
@Override public void encode(ChannelHandlerContext ctx, RpcCommand rpcCommand, ByteBuf out) throws Exception { try {//w w w . j a va 2s .com ByteBuffer header = rpcCommand.encodeHeader(); out.writeBytes(header); byte[] body = rpcCommand.getBody(); if (body != null) { out.writeBytes(body); } } catch (Exception e) { LOGGER.error("encode exception, " + RpcHelper.parseChannelRemoteAddr(ctx.channel()), e); if (rpcCommand != null) { LOGGER.error(rpcCommand.toString()); } RpcHelper.closeChannel(ctx.channel()); } }