use of org.apache.ignite.spi.discovery.DiscoveryDataBag in project ignite by apache.
the class DiscoveryDataPacket method unmarshalGridData.
/**
* @param marsh Marsh.
* @param clsLdr Class loader.
* @param clientNode Client node.
* @param log Logger.
*/
public DiscoveryDataBag unmarshalGridData(Marshaller marsh, ClassLoader clsLdr, boolean clientNode, IgniteLogger log) {
DiscoveryDataBag dataBag = new DiscoveryDataBag(joiningNodeId, joiningNodeClient);
if (commonData != null && !commonData.isEmpty()) {
Map<Integer, Serializable> unmarshCommonData = unmarshalData(commonData, marsh, clsLdr, clientNode, log);
dataBag.commonData(unmarshCommonData);
}
if (nodeSpecificData != null && !nodeSpecificData.isEmpty()) {
Map<UUID, Map<Integer, Serializable>> unmarshNodeSpecData = U.newLinkedHashMap(nodeSpecificData.size());
for (Map.Entry<UUID, Map<Integer, byte[]>> nodeBinEntry : nodeSpecificData.entrySet()) {
Map<Integer, byte[]> nodeBinData = nodeBinEntry.getValue();
if (nodeBinData == null || nodeBinData.isEmpty())
continue;
Map<Integer, Serializable> unmarshData = unmarshalData(nodeBinData, marsh, clsLdr, clientNode, log);
unmarshNodeSpecData.put(nodeBinEntry.getKey(), unmarshData);
}
dataBag.nodeSpecificData(unmarshNodeSpecData);
}
return dataBag;
}
use of org.apache.ignite.spi.discovery.DiscoveryDataBag in project ignite by apache.
the class DiscoveryDataPacket method unmarshalJoiningNodeData.
/**
* @param marsh Marsh.
* @param clsLdr Class loader.
* @param clientNode Client node.
* @param log Logger.
*/
public DiscoveryDataBag unmarshalJoiningNodeData(Marshaller marsh, ClassLoader clsLdr, boolean clientNode, IgniteLogger log) {
DiscoveryDataBag dataBag = new DiscoveryDataBag(joiningNodeId, joiningNodeClient);
if (joiningNodeData != null && !joiningNodeData.isEmpty()) {
unmarshalledJoiningNodeData = unmarshalData(joiningNodeData, marsh, clsLdr, clientNode, log);
dataBag.joiningNodeData(unmarshalledJoiningNodeData);
}
return dataBag;
}
use of org.apache.ignite.spi.discovery.DiscoveryDataBag in project ignite by apache.
the class GridSpiAbstractTest method spiStart.
/**
* @throws Exception If failed.
*/
@SuppressWarnings({ "unchecked", "CastToIncompatibleInterface", "InstanceofIncompatibleInterface" })
protected final void spiStart() throws Exception {
GridSpiTest spiTest = GridTestUtils.getAnnotation(getClass(), GridSpiTest.class);
assert spiTest != null;
T spi = (T) spiTest.spi().newInstance();
// Set spi into test data.
getTestData().setSpi(spi);
if (!(spi instanceof DiscoverySpi)) {
if (spiTest.triggerDiscovery())
configureDiscovery(spiTest);
} else
getTestData().setDiscoverySpi((DiscoverySpi) spi);
getTestResources().inject(spi);
spiConfigure(spi);
Map<String, Object> attrs = spi.getNodeAttributes();
// Set up SPI class name and SPI version.
Map<String, Serializable> spiAttrs = initSpiClassAndVersionAttributes(spi);
if (attrs != null)
getTestData().getAttributes().putAll(attrs);
if (spiAttrs != null)
getTestData().getAttributes().putAll(spiAttrs);
Map<String, Serializable> nodeAttrs = getNodeAttributes();
if (nodeAttrs != null)
getTestData().getAttributes().putAll(nodeAttrs);
DiscoverySpi discoSpi = getTestData().getDiscoverySpi();
if (spiTest.triggerDiscovery() && !getTestData().isDiscoveryTest()) {
getTestData().getAttributes().putAll(initSpiClassAndVersionAttributes(discoSpi));
// Set all local node attributes into discovery SPI.
discoSpi.setNodeAttributes(getTestData().getAttributes(), VERSION);
discoSpi.setMetricsProvider(createMetricsProvider());
discoSpi.setDataExchange(new DiscoverySpiDataExchange() {
@Override
public DiscoveryDataBag collect(DiscoveryDataBag dataBag) {
return dataBag;
}
@Override
public void onExchange(DiscoveryDataBag dataBag) {
// No-op.
}
});
try {
spiStart(discoSpi);
} catch (Exception e) {
spiStop(discoSpi);
throw e;
}
}
if (spi instanceof DiscoverySpi) {
getTestData().getAttributes().putAll(initSpiClassAndVersionAttributes(spi));
((DiscoverySpi) spi).setNodeAttributes(getTestData().getAttributes(), VERSION);
((DiscoverySpi) spi).setMetricsProvider(createMetricsProvider());
}
try {
spiStart(spi);
} catch (Exception e) {
spiStop(spi);
if (discoSpi != null && !discoSpi.equals(spi))
spiStop(discoSpi);
afterSpiStopped();
throw e;
}
// Initialize SPI context.
getTestData().setSpiContext(initSpiContext());
// Initialize discovery SPI only once.
if (discoSpi != null && !discoSpi.equals(spi))
discoSpi.onContextInitialized(getSpiContext());
spi.onContextInitialized(getTestData().getSpiContext());
}
Aggregations