Java Code Examples for org.nustaq.serialization.FSTConfiguration#createDefaultConfiguration()

The following examples show how to use org.nustaq.serialization.FSTConfiguration#createDefaultConfiguration() . 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: Serializer.java    From meghanada-server with GNU General Public License v3.0 6 votes vote down vote up
public static FSTConfiguration getFST() {
  if (fst != null) {
    return fst;
  }
  FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration();
  conf.registerClass(
      Project.class,
      ProjectDependency.class,
      GradleProject.class,
      MavenProject.class,
      MeghanadaProject.class,
      ParameterName.class,
      MethodParameterNames.class,
      Scope.class,
      LineRange.class,
      Position.class,
      Variable.class,
      Range.class,
      Source.class,
      MethodParameter.class,
      ClassIndex.class,
      MemberDescriptor.class);
  fst = conf;
  return fst;
}
 
Example 2
Source File: FstExample.java    From chuidiang-ejemplos with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration();

    SomeMediumClass mediumClass = new SomeMediumClass();
    byte barray[] = conf.asByteArray(mediumClass);
    System.out.println(barray.length);
    SomeMediumClass object = (SomeMediumClass)conf.asObject(barray);
    System.out.println(object);


    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    FSTObjectOutput output = new FSTObjectOutput(outputStream);
    output.writeObject(mediumClass);
    output.close();

    FSTObjectInput input = new FSTObjectInput(new ByteArrayInputStream(outputStream.toByteArray()));
    object = (SomeMediumClass)input.readObject(SomeMediumClass.class);
    System.out.println(object);
}
 
Example 3
Source File: SerializerCore.java    From htm.java with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Initializes the delegate serializer
 */
private void initFST() {
    fastSerialConfig = FSTConfiguration.createDefaultConfiguration();
    if(classes != null) {
        fastSerialConfig.registerClass(classes);
    }
}
 
Example 4
Source File: FSTSerializer.java    From Hive2Hive with MIT License 5 votes vote down vote up
/**
 * Create a FST serializer (faster and more efficient than Java default serialization).
 * 
 * @param useUnsafe <code>true</code> to use <code>sun.misc.Unsafe</code> class, otherwise, a fallback is
 *            used.
 * @param securityProvider the security provider, needed to decode key pairs correctly
 */
public FSTSerializer(boolean useUnsafe, ISecurityClassProvider securityProvider) {
	if (!useUnsafe) {
		// don't use sun.misc.Unsafe class
		FSTUtil.unFlaggedUnsafe = null;
		logger.debug("Disabled the use of 'sun.misc.Unsafe' for the serialization");
	}

	fst = FSTConfiguration.createDefaultConfiguration();

	// register all often serialized classes for speedup. Note that every peer should have the same
	// configuration, which also depends on the order! Changing these registrations might break backward
	// compatibility!
	fst.registerClass(UserProfile.class, FolderIndex.class, FileIndex.class, UserPermission.class, Locations.class,
			UserPublicKey.class, MetaFileSmall.class, MetaFileLarge.class, FileVersion.class, MetaChunk.class,
			Chunk.class, EncryptedNetworkContent.class, ContactPeerMessage.class, ResponseMessage.class);

	// for all public / private keys for full compatibility among multiple security providers
	fst.registerClass(securityProvider.getRSAPublicKeyClass(), securityProvider.getRSAPrivateKeyClass(),
			securityProvider.getRSAPrivateCrtKeyClass());

	// for performance improvements, native TomP2P classes which are serialized quite often
	fst.registerClass(PeerAddress.class, PeerSocketAddress.class, Number160.class);

	// Since PeerAddresses are serialized very often, this is just an efficiency improvement
	fst.registerSerializer(PeerAddress.class, new FSTPeerAddressSerializer(), false);

	// register the acceptance reply enum
	fst.registerClass(AcceptanceReply.class);
}
 
Example 5
Source File: ObjectUtils.java    From frpMgr with MIT License 4 votes vote down vote up
public FSTConfiguration initialValue() {
	return FSTConfiguration.createDefaultConfiguration();
}
 
Example 6
Source File: GridNode.java    From vlingo-lattice with Mozilla Public License 2.0 4 votes vote down vote up
public GridNode(final GridRuntime gridRuntime, final Node localNode) {
  this.gridRuntime = gridRuntime;
  this.localNode = localNode;

  final FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration();
  // set classloader with available proxy classes
  conf.setClassLoader(gridRuntime.worldClassLoader());

  final HardRefHolder holder = gridRuntime.world().actorFor(HardRefHolder.class,
      Definition.has(ExpiringHardRefHolder.class, ExpiringHardRefHolder::new));

  this.outbound =
          stage().actorFor(
                  GridActorControl.Outbound.class,
                  OutboundGridActorControl.class,
                  new OutboundGridActorControlInstantiator(
                                  localNode.id(),
                                  new FSTEncoder(conf),
                                  correlation::put,
                                  new OutBuffers(holder)));

  this.gridRuntime.setOutbound(outbound);

  final GridActorControl.Inbound inbound =
          stage().actorFor(
                  GridActorControl.Inbound.class,
                  InboundGridActorControl.class,
                  new InboundGridActorControlInstantiator(
                          gridRuntime,
                          correlation::remove));

  this.applicationMessageHandler =
          new GridApplicationMessageHandler(
                  localNode.id(),
                  gridRuntime.hashRing(),
                  inbound,
                  outbound,
                  new FSTDecoder(conf), holder,
                  scheduler());

  this.quorumObservers = new ArrayList<>(3);

  registerQuorumObserver(gridRuntime);
}
 
Example 7
Source File: FstSerializer.java    From mango with Apache License 2.0 4 votes vote down vote up
@Override
public FSTConfiguration load(Class<?> cls) throws Exception {
    return FSTConfiguration.createDefaultConfiguration();
}
 
Example 8
Source File: FSTSerializerImpl.java    From utils with Apache License 2.0 4 votes vote down vote up
public FSTSerializerImpl() {
    conf = FSTConfiguration.createDefaultConfiguration();
    conf.setForceSerializable(true);
}
 
Example 9
Source File: FstSerializer.java    From netty-learning with Apache License 2.0 4 votes vote down vote up
@Override
public FSTConfiguration load(Class<?> cls) throws Exception {
    return FSTConfiguration.createDefaultConfiguration();
}
 
Example 10
Source File: FSTSerializerFactory.java    From Thunder with Apache License 2.0 4 votes vote down vote up
public static FSTConfiguration createFST() {
    FSTConfiguration fst = FSTConfiguration.createDefaultConfiguration();

    return fst;
}
 
Example 11
Source File: TemporalMemoryTest.java    From htm.java with GNU Affero General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private <T> T deepCopyPlain(T t) {
    FSTConfiguration fastSerialConfig = FSTConfiguration.createDefaultConfiguration();
    byte[] bytes = fastSerialConfig.asByteArray(t);
    return (T)fastSerialConfig.asObject(bytes);
}
 
Example 12
Source File: FstCodec.java    From redisson with Apache License 2.0 4 votes vote down vote up
public FstCodec() {
    this(FSTConfiguration.createDefaultConfiguration());
}
 
Example 13
Source File: FstCodec.java    From redisson with Apache License 2.0 4 votes vote down vote up
private static FSTConfiguration createConfig(ClassLoader classLoader) {
    FSTConfiguration def = FSTConfiguration.createDefaultConfiguration();
    def.setClassLoader(classLoader);
    return def;
}