use of org.apache.ignite.internal.processors.marshaller.MappedName 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);
}
}
use of org.apache.ignite.internal.processors.marshaller.MappedName in project ignite by apache.
the class MarshallerContextImpl method getClassName.
/**
* {@inheritDoc}
*/
@Override
public String getClassName(byte platformId, int typeId) throws ClassNotFoundException, IgniteCheckedException {
ConcurrentMap<Integer, MappedName> cache = getCacheFor(platformId);
MappedName mappedName = cache.get(typeId);
String clsName;
if (mappedName != null)
clsName = mappedName.className();
else {
clsName = fileStore.readMapping(platformId, typeId);
if (clsName != null)
cache.putIfAbsent(typeId, new MappedName(clsName, true));
else if (clientNode) {
mappedName = cache.get(typeId);
if (mappedName == null) {
GridFutureAdapter<MappingExchangeResult> fut = transport.requestMapping(new MarshallerMappingItem(platformId, typeId, null), cache);
clsName = fut.get().className();
} else
clsName = mappedName.className();
if (clsName == null)
throw new ClassNotFoundException("Requesting mapping from grid failed for [platformId=" + platformId + ", typeId=" + typeId + "]");
return clsName;
} else
throw new ClassNotFoundException("Unknown pair [platformId=" + platformId + ", typeId=" + typeId + "]");
}
return clsName;
}
use of org.apache.ignite.internal.processors.marshaller.MappedName in project ignite by apache.
the class MarshallerContextImpl method onMappingProposed.
/**
* @param item type mapping to propose
* @return null if cache doesn't contain any mappings for given (platformId, typeId) pair,
* previous {@link MappedName mapped name} otherwise.
*/
public MappedName onMappingProposed(MarshallerMappingItem item) {
ConcurrentMap<Integer, MappedName> cache = getCacheFor(item.platformId());
MappedName newName = new MappedName(item.className(), false);
return cache.putIfAbsent(item.typeId(), newName);
}
use of org.apache.ignite.internal.processors.marshaller.MappedName 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);
}
}
use of org.apache.ignite.internal.processors.marshaller.MappedName in project ignite by apache.
the class MarshallerContextImpl method registerClassNameLocally.
/**
* {@inheritDoc}
*/
@Override
public boolean registerClassNameLocally(byte platformId, int typeId, String clsName) throws IgniteCheckedException {
ConcurrentMap<Integer, MappedName> cache = getCacheFor(platformId);
fileStore.mergeAndWriteMapping(platformId, typeId, clsName);
cache.put(typeId, new MappedName(clsName, true));
return true;
}
Aggregations