本文整理匯總了Java中com.esotericsoftware.kryo.io.Output類的典型用法代碼示例。如果您正苦於以下問題:Java Output類的具體用法?Java Output怎麽用?Java Output使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Output類屬於com.esotericsoftware.kryo.io包,在下文中一共展示了Output類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: run
import com.esotericsoftware.kryo.io.Output; //導入依賴的package包/類
@Override
public void run() {
try {
while (true) {
MetaData metaData = sendQueue.take();
Output output = getOutput(metaData.getDestRank());
operand.send(output, metaData);
}
} catch (Exception e) {
try {
exception(e);
} catch (Mp4jException e1) {
LOG.error("Mp4jException", e);
}
}
}
示例2: write
import com.esotericsoftware.kryo.io.Output; //導入依賴的package包/類
@Override
public void write(final Kryo kryo, final Output output, final RegisteredService service) {
kryo.writeObject(output, service.getServiceId());
kryo.writeObject(output, StringUtils.defaultIfEmpty(service.getName(), ""));
kryo.writeObject(output, StringUtils.defaultIfEmpty(service.getDescription(), ""));
kryo.writeObject(output, service.getId());
kryo.writeObject(output, service.getEvaluationOrder());
kryo.writeObject(output, ObjectUtils.defaultIfNull(service.getLogo(), getEmptyUrl()));
kryo.writeObject(output, service.getLogoutType());
kryo.writeObject(output, ObjectUtils.defaultIfNull(service.getLogoutUrl(), getEmptyUrl()));
kryo.writeObject(output, ImmutableSet.copyOf(service.getRequiredHandlers()));
kryo.writeObject(output, StringUtils.defaultIfEmpty(service.getTheme(), ""));
writeObjectByReflection(kryo, output, ObjectUtils.defaultIfNull(service.getPublicKey(),
new RegisteredServicePublicKeyImpl()));
writeObjectByReflection(kryo, output, ObjectUtils.defaultIfNull(service.getProxyPolicy(),
new RefuseRegisteredServiceProxyPolicy()));
writeObjectByReflection(kryo, output, ObjectUtils.defaultIfNull(service.getAttributeReleasePolicy(),
new ReturnAllowedAttributeReleasePolicy()));
writeObjectByReflection(kryo, output, ObjectUtils.defaultIfNull(service.getUsernameAttributeProvider(),
new DefaultRegisteredServiceUsernameProvider()));
writeObjectByReflection(kryo, output, ObjectUtils.defaultIfNull(service.getAccessStrategy(),
new DefaultRegisteredServiceAccessStrategy()));
}
示例3: encode
import com.esotericsoftware.kryo.io.Output; //導入依賴的package包/類
@Override
public ByteBuf encode(Object in) throws IOException {
Kryo kryo = null;
ByteBuf out = ByteBufAllocator.DEFAULT.buffer();
try {
ByteBufOutputStream baos = new ByteBufOutputStream(out);
Output output = new Output(baos);
kryo = kryoPool.get();
kryo.writeClassAndObject(output, in);
output.close();
return baos.buffer();
} catch (Exception e) {
out.release();
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
}
throw new RedissonKryoCodecException(e);
} finally {
if (kryo != null) {
kryoPool.yield(kryo);
}
}
}
示例4: write
import com.esotericsoftware.kryo.io.Output; //導入依賴的package包/類
public void write(Kryo kryo, Output output, ArrayMetaData<long[]> object) {
try {
long[] arrData = arrayMetaData.getArrData();
arrayMetaData.send(output);
int arrSegNum = arrayMetaData.getSegNum();
for (int i = 0; i < arrSegNum; i++) {
int from = arrayMetaData.getFrom(i);
int to = arrayMetaData.getTo(i);
for (int j = from; j < to; j++) {
output.writeLong(arrData[j]);
}
}
} catch (IOException e) {
LOG.error("double array write exception", e);
System.exit(1);
}
}
示例5: serialize
import com.esotericsoftware.kryo.io.Output; //導入依賴的package包/類
@Override
public byte[] serialize(Object obj) throws SerializerException {
byte[] bytes;
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try {
//獲取kryo對象
Kryo kryo = new Kryo();
Output output = new Output(outputStream);
kryo.writeObject(output, obj);
bytes = output.toBytes();
output.flush();
} catch (Exception ex) {
throw new SerializerException("kryo serialize error" + ex.getMessage());
} finally {
try {
outputStream.flush();
outputStream.close();
} catch (IOException e) {
}
}
return bytes;
}
示例6: write
import com.esotericsoftware.kryo.io.Output; //導入依賴的package包/類
public void write(Kryo kryo, Output output, ArrayMetaData<short[]> object) {
try {
short[] arrData = arrayMetaData.getArrData();
arrayMetaData.send(output);
int arrSegNum = arrayMetaData.getSegNum();
for (int i = 0; i < arrSegNum; i++) {
int from = arrayMetaData.getFrom(i);
int to = arrayMetaData.getTo(i);
for (int j = from; j < to; j++) {
output.writeShort(arrData[j]);
}
}
} catch (IOException e) {
LOG.error("double array write exception", e);
System.exit(1);
}
}
示例7: write
import com.esotericsoftware.kryo.io.Output; //導入依賴的package包/類
public void write(Kryo kryo, Output output, ArrayMetaData<byte[]> object) {
try {
byte[] arrData = arrayMetaData.getArrData();
arrayMetaData.send(output);
int arrSegNum = arrayMetaData.getSegNum();
for (int i = 0; i < arrSegNum; i++) {
int from = arrayMetaData.getFrom(i);
int to = arrayMetaData.getTo(i);
for (int j = from; j < to; j++) {
output.writeByte(arrData[j]);
}
}
} catch (IOException e) {
LOG.error("double array write exception", e);
System.exit(1);
}
}
示例8: serialize
import com.esotericsoftware.kryo.io.Output; //導入依賴的package包/類
/**
* 序列化
*
* @param obj 需要序更列化的對象
* @return 序列化後的byte 數組
* @throws TccException
*/
@Override
public byte[] serialize(Object obj) throws TccException {
byte[] bytes;
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
//獲取kryo對象
Kryo kryo = new Kryo();
Output output = new Output(outputStream);
kryo.writeObject(output, obj);
bytes = output.toBytes();
output.flush();
} catch (Exception ex) {
throw new TccException("kryo serialize error" + ex.getMessage());
}
return bytes;
}
示例9: apply
import com.esotericsoftware.kryo.io.Output; //導入依賴的package包/類
@Override
public byte[] apply(Object value) {
try {
Kryo kryo = kryoThreadLocal.get();
ByteArrayOutputStream bos = new ByteArrayOutputStream(256);
Output output = new Output(bos);
output.writeInt(IDENTITY_NUMBER);
kryo.writeClassAndObject(output, value);
output.close();
return bos.toByteArray();
} catch (Exception e) {
StringBuilder sb = new StringBuilder("Kryo Encode error. ");
sb.append("msg=").append(e.getMessage());
throw new CacheEncodeException(sb.toString(), e);
}
}
示例10: encode
import com.esotericsoftware.kryo.io.Output; //導入依賴的package包/類
protected void encode(ChannelHandlerContext channelHandlerContext, Object o, ByteBuf byteBuf) throws Exception {
if(clazz.isInstance(o)){
Kryo kryo = null;
try{
kryo = pool.borrow();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Output output = new Output(baos);
kryo.writeObject(output, o);
output.flush();
output.close();
byte[] data = baos.toByteArray();
byteBuf.writeInt(data.length);
byteBuf.writeBytes(data);
baos.close();
}catch(Exception e){
LOG.warn("MessageEncoder happen exception.", e);
}finally{
if(kryo != null){
pool.release(kryo);
}
}
}
}
示例11: write
import com.esotericsoftware.kryo.io.Output; //導入依賴的package包/類
public void write (Kryo kryo, Output output, LongMap map) {
int length = map.size;
output.writeVarInt(length, true);
output.writeBoolean(false); // whether type is written (in case future version of LongMap supports type awareness)
Serializer valueSerializer = null;
if (valueGenericType != null) {
if (valueSerializer == null) valueSerializer = kryo.getSerializer(valueGenericType);
valueGenericType = null;
}
for (Iterator iter = map.iterator(); iter.hasNext();) {
LongMap.Entry entry = (LongMap.Entry)iter.next();
output.writeLong(entry.key);
if (valueSerializer != null) {
kryo.writeObjectOrNull(output, entry.value, valueSerializer);
} else
kryo.writeClassAndObject(output, entry.value);
}
}
示例12: writeTable
import com.esotericsoftware.kryo.io.Output; //導入依賴的package包/類
private <E> void writeTable(String key, RakTable<E> paperTable, File originalFile, File backupFile) {
try {
FileOutputStream file = new FileOutputStream(originalFile);
final Output kryoOutput = new Output(file);
getKryo().writeObject(kryoOutput, paperTable);
kryoOutput.flush();
file.flush();
sync(file);
kryoOutput.close();
backupFile.delete();
} catch (IOException e) {
if (originalFile.exists()) {
if (!originalFile.delete()) {
throw new RuntimeException("cant deleted");
}
}
throw new RuntimeException("cant save to table " + key, e);
}
}
示例13: write
import com.esotericsoftware.kryo.io.Output; //導入依賴的package包/類
public void write(Kryo kryo, Output output, ArrayMetaData<String[]> object) {
try {
String[] arrData = arrayMetaData.getArrData();
arrayMetaData.send(output);
int arrSegNum = arrayMetaData.getSegNum();
for (int i = 0; i < arrSegNum; i++) {
int from = arrayMetaData.getFrom(i);
int to = arrayMetaData.getTo(i);
for (int j = from; j < to; j++) {
output.writeString(arrData[j]);
}
}
} catch (IOException e) {
LOG.error("double array write exception", e);
System.exit(1);
}
}
示例14: write
import com.esotericsoftware.kryo.io.Output; //導入依賴的package包/類
public void write(Kryo kryo, Output output, MapMetaData<Float> object) {
try {
List<Map<String, Float>> mapDataList = mapMetaData.getMapDataList();
mapMetaData.send(output);
int mapSegNum = mapMetaData.getSegNum();
for (int i = 0; i < mapSegNum; i++) {
Map<String, Float> mapData = mapDataList.get(i);
for (Map.Entry<String, Float> entry : mapData.entrySet()) {
output.writeString(entry.getKey());
output.writeFloat(entry.getValue());
}
if (mapMetaData.getCollective() == Collective.GATHER ||
mapMetaData.getCollective() == Collective.SCATTER ||
mapMetaData.getCollective() == Collective.REDUCE_SCATTER) {
mapData.clear();
}
}
} catch (IOException e) {
LOG.error("double array write exception", e);
System.exit(1);
}
}
示例15: serialize
import com.esotericsoftware.kryo.io.Output; //導入依賴的package包/類
/**
* 序列化
*
* @param obj 需要序更列化的對象
* @return 序列化後的byte 數組
* @throws MythException 異常
*/
@Override
public byte[] serialize(Object obj) throws MythException {
byte[] bytes;
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
//獲取kryo對象
Kryo kryo = new Kryo();
Output output = new Output(outputStream);
kryo.writeObject(output, obj);
bytes = output.toBytes();
output.flush();
} catch (Exception ex) {
throw new MythException("kryo serialize error" + ex.getMessage());
}
return bytes;
}