@Override public void deserialize(byte[] data) { vlanId = APPKRYO.deserialize(data); }
@Override public byte[] data() { return Ofdpa2Pipeline.appKryo.serialize(gkeys); } }
/** * Builds a {@link KryoNamespace} instance. * * @param friendlyName friendly name for the namespace * @return KryoNamespace */ public KryoNamespace build(String friendlyName) { if (!types.isEmpty()) { blocks.add(new RegistrationBlock(this.blockHeadId, types)); } return new KryoNamespace(blocks, registrationRequired, compatible, friendlyName).populate(1); }
@Activate public void activate() { eventDispatcher.addSink(PiPipeconfWatchdogEvent.class, listenerRegistry); localStatusMap = Maps.newConcurrentMap(); // Init distributed status map. KryoNamespace.Builder serializer = KryoNamespace.newBuilder() .register(KryoNamespaces.API) .register(PipelineStatus.class); statusMap = storageService.<DeviceId, PipelineStatus>eventuallyConsistentMapBuilder() .withName("onos-pipeconf-status-table") .withSerializer(serializer) .withTimestampProvider((k, v) -> new WallClockTimestamp()).build(); statusMap.addListener(new StatusMapListener()); // Register component configurable properties. componentConfigService.registerProperties(getClass()); // Start periodic watchdog task. timer = new Timer(); startProbeTask(); // Add device listener. deviceService.addListener(deviceListener); log.info("Started"); }
GroupKey l3ecmpGroupKey = new DefaultGroupKey(Ofdpa2Pipeline.appKryo.serialize(l3ecmpGroupId)); List<Deque<GroupKey>> allOriginalKeys = Ofdpa2Pipeline.appKryo.deserialize(next.data()); allOriginalKeys.add(newBucketChain); flowObjectiveStore.putNextGroup(nextObjective.id(),
/** * Deserializes given byte array to Object using Kryo instance in pool. * * @param bytes serialized bytes * @param <T> deserialized Object type * @return deserialized Object */ public <T> T deserialize(final byte[] bytes) { Input in = new Input(new ByteArrayInputStream(bytes)); Kryo kryo = borrow(); try { @SuppressWarnings("unchecked") T obj = (T) kryo.readClassAndObject(in); return obj; } finally { release(kryo); } }
@Activate public void activate() { appId = coreService.registerApplication(VTNRSC_APP); KryoNamespace.Builder serializer = KryoNamespace .newBuilder() .register(KryoNamespaces.API) .register(RouterId.class, TenantId.class, VirtualPortId.class, RouterInterface.class, SubnetId.class); routerInterfaceStore = storageService .<SubnetId, RouterInterface>eventuallyConsistentMapBuilder() .withName(ROUTER_INTERFACE).withSerializer(serializer) .withTimestampProvider((k, v) -> new WallClockTimestamp()) .build(); routerInterfaceStore.addListener(routerInterfaceListener); log.info("Started"); }
/** * Deserializes given InputStream to an Object using Kryo instance in pool. * * @param stream input stream * @param <T> deserialized Object type * @return deserialized Object * @param bufferSize size of the buffer in front of the stream */ public <T> T deserialize(final InputStream stream, final int bufferSize) { ByteBufferInput in = new ByteBufferInput(stream, bufferSize); Kryo kryo = borrow(); try { @SuppressWarnings("unchecked") T obj = (T) kryo.readClassAndObject(in); return obj; } finally { release(kryo); } }
@Activate public void activate() { appId = coreService.registerApplication(VTNRSC_APP); KryoNamespace.Builder serializer = KryoNamespace .newBuilder() .register(KryoNamespaces.API) .register(RouterId.class, TenantId.class, VirtualPortId.class, RouterInterface.class, SubnetId.class); routerInterfaceStore = storageService .<SubnetId, RouterInterface>eventuallyConsistentMapBuilder() .withName(ROUTER_INTERFACE).withSerializer(serializer) .withTimestampProvider((k, v) -> new WallClockTimestamp()) .build(); routerInterfaceStore.addListener(routerInterfaceListener); log.info("Started"); }
@Override public byte[] data() { return appKryo.serialize(key); }
@Override public void deserialize(byte[] data) { nshNp = (byte) (appKryo.deserialize(data)); }
/** * Deserializes given byte buffer to Object using Kryo instance in pool. * * @param buffer input with serialized bytes * @param <T> deserialized Object type * @return deserialized Object */ public <T> T deserialize(final ByteBuffer buffer) { ByteBufferInput in = new ByteBufferInput(buffer); Kryo kryo = borrow(); try { @SuppressWarnings("unchecked") T obj = (T) kryo.readClassAndObject(in); return obj; } finally { release(kryo); } }
@Activate protected void activate() { eventDispatcher.addSink(FlowClassifierEvent.class, listenerRegistry); KryoNamespace.Builder serializer = KryoNamespace.newBuilder() .register(KryoNamespaces.API) .register(MultiValuedTimestamp.class) .register(FlowClassifier.class, FlowClassifierId.class, UUID.class, IpPrefix.class, VirtualPortId.class, DefaultFlowClassifier.class, TenantId.class); flowClassifierStore = storageService .<FlowClassifierId, FlowClassifier>eventuallyConsistentMapBuilder() .withName("flowclassifierstore").withSerializer(serializer) .withTimestampProvider((k, v) -> new WallClockTimestamp()).build(); flowClassifierStore.addListener(flowClassifierListener); log.info("Flow Classifier service activated"); }
/** * Serializes given object to byte array using Kryo instance in pool. * <p> * Note: Serialized bytes must be smaller than {@link #MAX_BUFFER_SIZE}. * * @param obj Object to serialize * @return serialized bytes */ public byte[] serialize(final Object obj) { return serialize(obj, DEFAULT_BUFFER_SIZE); }
@Override public void deserialize(byte[] data) { encapEthType = (short) (appKryo.deserialize(data)); }
/** * Serializes given object to byte buffer using Kryo instance in pool. * * @param obj Object to serialize * @param buffer to write to */ public void serialize(final Object obj, final ByteBuffer buffer) { ByteBufferOutput out = new ByteBufferOutput(buffer); Kryo kryo = borrow(); try { kryo.writeClassAndObject(out, obj); out.flush(); } finally { release(kryo); } }
@Activate public void activate() { eventDispatcher.addSink(PortPairEvent.class, listenerRegistry); KryoNamespace.Builder serializer = KryoNamespace.newBuilder() .register(KryoNamespaces.API) .register(MultiValuedTimestamp.class) .register(PortPair.class, PortPairId.class, UUID.class, DefaultPortPair.class, TenantId.class); portPairStore = storageService.<PortPairId, PortPair>eventuallyConsistentMapBuilder() .withName("portpairstore") .withSerializer(serializer) .withTimestampProvider((k, v) -> new WallClockTimestamp()) .build(); portPairStore.addListener(portPairListener); log.info("Started"); }
/** * Serializes given object to OutputStream using Kryo instance in pool. * * @param obj Object to serialize * @param stream to write to */ public void serialize(final Object obj, final OutputStream stream) { serialize(obj, stream, DEFAULT_BUFFER_SIZE); }
@Override public void deserialize(byte[] data) { nshMdType = (byte) (appKryo.deserialize(data)); }