Search in sources :

Example 1 with MappingExchangeResult

use of org.apache.ignite.internal.processors.marshaller.MappingExchangeResult in project ignite by apache.

the class MarshallerContextImpl method registerClassName.

/**
 * {@inheritDoc}
 */
@Override
public boolean registerClassName(byte platformId, int typeId, String clsName) throws IgniteCheckedException {
    ConcurrentMap<Integer, MappedName> cache = getCacheFor(platformId);
    MappedName mappedName = cache.get(typeId);
    if (mappedName != null) {
        if (!mappedName.className().equals(clsName))
            throw new DuplicateTypeIdException(platformId, typeId, mappedName.className(), clsName);
        else {
            if (mappedName.accepted())
                return true;
            if (transport.stopping())
                return false;
            IgniteInternalFuture<MappingExchangeResult> fut = transport.awaitMappingAcceptance(new MarshallerMappingItem(platformId, typeId, clsName), cache);
            MappingExchangeResult res = fut.get();
            return convertXchRes(res);
        }
    } else {
        if (transport.stopping())
            return false;
        IgniteInternalFuture<MappingExchangeResult> fut = transport.proposeMapping(new MarshallerMappingItem(platformId, typeId, clsName), cache);
        MappingExchangeResult res = fut.get();
        return convertXchRes(res);
    }
}
Also used : MarshallerMappingItem(org.apache.ignite.internal.processors.marshaller.MarshallerMappingItem) MappingExchangeResult(org.apache.ignite.internal.processors.marshaller.MappingExchangeResult) MappedName(org.apache.ignite.internal.processors.marshaller.MappedName)

Example 2 with MappingExchangeResult

use of org.apache.ignite.internal.processors.marshaller.MappingExchangeResult in project ignite by apache.

the class MarshallerContextImpl method registerClassName.

/**
 * {@inheritDoc}
 */
@Override
public boolean registerClassName(byte platformId, int typeId, String clsName, boolean failIfUnregistered) throws IgniteCheckedException {
    ConcurrentMap<Integer, MappedName> cache = getCacheFor(platformId);
    MappedName mappedName = cache.get(typeId);
    if (mappedName != null) {
        if (!mappedName.className().equals(clsName))
            throw new DuplicateTypeIdException(platformId, typeId, mappedName.className(), clsName);
        else {
            if (mappedName.accepted())
                return true;
            if (transport.stopping())
                return false;
            MarshallerMappingItem item = new MarshallerMappingItem(platformId, typeId, clsName);
            GridFutureAdapter<MappingExchangeResult> fut = transport.awaitMappingAcceptance(item, cache);
            if (failIfUnregistered && !fut.isDone())
                throw new UnregisteredBinaryTypeException(typeId, fut);
            MappingExchangeResult res = fut.get();
            return convertXchRes(res);
        }
    } else {
        if (transport.stopping())
            return false;
        MarshallerMappingItem item = new MarshallerMappingItem(platformId, typeId, clsName);
        GridFutureAdapter<MappingExchangeResult> fut = transport.proposeMapping(item, cache);
        if (failIfUnregistered && !fut.isDone())
            throw new UnregisteredBinaryTypeException(typeId, fut);
        MappingExchangeResult res = fut.get();
        return convertXchRes(res);
    }
}
Also used : MarshallerMappingItem(org.apache.ignite.internal.processors.marshaller.MarshallerMappingItem) MappingExchangeResult(org.apache.ignite.internal.processors.marshaller.MappingExchangeResult) MappedName(org.apache.ignite.internal.processors.marshaller.MappedName)

Aggregations

MappedName (org.apache.ignite.internal.processors.marshaller.MappedName)2 MappingExchangeResult (org.apache.ignite.internal.processors.marshaller.MappingExchangeResult)2 MarshallerMappingItem (org.apache.ignite.internal.processors.marshaller.MarshallerMappingItem)2