Skip to content

Commit

Permalink
# ignite-301 fixed serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
sboikov committed Feb 19, 2015
1 parent 4127e9d commit b5cc14f
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 20 deletions.
Expand Up @@ -96,7 +96,7 @@
* See <a href="http://en.wikipedia.org/wiki/Kernal">http://en.wikipedia.org/wiki/Kernal</a> for information on the
* misspelling.
*/
public class IgniteKernal implements IgniteEx, IgniteMXBean {
public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
/** */
private static final long serialVersionUID = 0L;

Expand Down Expand Up @@ -1788,13 +1788,10 @@ else if (state == STARTING)
try {
assert gw.getState() == STARTED || gw.getState() == STARTING;

ClusterNodeLocalMap locMap = cluster.nodeLocalMap();

// No more kernal calls from this point on.
gw.setState(STOPPING);

// Clear node local store.
locMap.clear();
cluster.clearNodeMap();

if (log.isDebugEnabled())
log.debug("Grid " + (gridName == null ? "" : '\'' + gridName + "' ") + "is stopping.");
Expand Down Expand Up @@ -2691,6 +2688,30 @@ private static String componentClassName(Class<?> cls) {
return cls.getPackage().getName() + ".os." + cls.getSimpleName().replace("Grid", "GridOs");
}

/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
gridName = U.readString(in);
}

/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
U.writeString(out, gridName);
}

/**
* @return IgniteKernal instance.
*
* @throws ObjectStreamException If failed.
*/
protected Object readResolve() throws ObjectStreamException {
try {
return IgnitionEx.gridx(gridName);
}
catch (IllegalStateException e) {
throw U.withCause(new InvalidObjectException(e.getMessage()), e);
}
}

/** {@inheritDoc} */
@Override public String toString() {
return S.toString(IgniteKernal.class, this);
Expand Down
Expand Up @@ -31,9 +31,20 @@
/**
*
*/
public class IgniteClusterAsyncImpl extends AsyncSupportAdapter<IgniteCluster> implements IgniteCluster {
public class IgniteClusterAsyncImpl extends AsyncSupportAdapter<IgniteCluster>
implements IgniteCluster, Externalizable {
/** */
private final IgniteClusterImpl cluster;
private static final long serialVersionUID = 0L;

/** */
private IgniteClusterImpl cluster;

/**
* Required by {@link Externalizable}.
*/
public IgniteClusterAsyncImpl() {
// No-op.
}

/**
* @param cluster Cluster.
Expand Down Expand Up @@ -259,4 +270,23 @@ public IgniteClusterAsyncImpl(IgniteClusterImpl cluster) {
@Override public ClusterMetrics metrics() {
return cluster.metrics();
}

/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
cluster = (IgniteClusterImpl)in.readObject();
}

/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
out.writeObject(cluster);
}

/**
* @return Cluster async instance.
*
* @throws ObjectStreamException If failed.
*/
protected Object readResolve() throws ObjectStreamException {
return cluster.withAsync();
}
}
Expand Up @@ -43,6 +43,9 @@
*
*/
public class IgniteClusterImpl extends ClusterGroupAdapter implements IgniteClusterEx, Externalizable {
/** */
private static final long serialVersionUID = 0L;

/** */
private IgniteConfiguration cfg;

Expand Down Expand Up @@ -486,6 +489,13 @@ private boolean runNextNodeCallable(final ConcurrentLinkedQueue<IgniteNodeCallab
return true;
}

/**
* Clears node local map.
*/
public void clearNodeMap() {
nodeLoc.clear();
}

/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
ctx = (GridKernalContext)in.readObject();
Expand Down
Expand Up @@ -157,14 +157,6 @@ org.apache.ignite.igfs.mapreduce.records.IgfsByteDelimiterRecordResolver
org.apache.ignite.igfs.mapreduce.records.IgfsFixedLengthRecordResolver
org.apache.ignite.igfs.mapreduce.records.IgfsNewLineRecordResolver
org.apache.ignite.igfs.mapreduce.records.IgfsStringDelimiterRecordResolver
org.apache.ignite.internal.ClusterGroupAdapter
org.apache.ignite.internal.ClusterGroupAdapter$AgeProjection
org.apache.ignite.internal.ClusterGroupAdapter$AttributeFilter
org.apache.ignite.internal.ClusterGroupAdapter$CachesFilter
org.apache.ignite.internal.ClusterGroupAdapter$DaemonFilter
org.apache.ignite.internal.ClusterGroupAdapter$OthersFilter
org.apache.ignite.internal.ClusterGroupAdapter$StreamersFilter
org.apache.ignite.internal.ClusterNodeLocalMapImpl
org.apache.ignite.internal.ComputeTaskInternalFuture
org.apache.ignite.internal.GridClosureCallMode
org.apache.ignite.internal.GridComponent$DiscoveryDataExchangeType
Expand All @@ -182,8 +174,6 @@ org.apache.ignite.internal.GridJobSiblingsResponse
org.apache.ignite.internal.GridKernalContextImpl
org.apache.ignite.internal.GridKernalGatewayImpl
org.apache.ignite.internal.GridKernalState
org.apache.ignite.internal.GridKillTask
org.apache.ignite.internal.GridKillTask$GridKillJob
org.apache.ignite.internal.GridLoggerProxy
org.apache.ignite.internal.GridMessageListenHandler
org.apache.ignite.internal.GridNodeOrderComparator
Expand Down Expand Up @@ -211,7 +201,6 @@ org.apache.ignite.internal.IgniteKernal
org.apache.ignite.internal.IgniteKernal$1
org.apache.ignite.internal.IgniteKernal$5
org.apache.ignite.internal.IgniteKernal$6
org.apache.ignite.internal.IgniteKernal$7
org.apache.ignite.internal.IgniteMessagingImpl
org.apache.ignite.internal.IgniteSchedulerImpl
org.apache.ignite.internal.IgniteServicesImpl
Expand Down Expand Up @@ -240,8 +229,21 @@ org.apache.ignite.internal.client.impl.connection.GridClientNioTcpConnection$7
org.apache.ignite.internal.client.impl.connection.GridClientNioTcpConnection$TcpClientFuture
org.apache.ignite.internal.client.impl.connection.GridClientTopology$1
org.apache.ignite.internal.client.impl.connection.GridConnectionIdleClosedException
org.apache.ignite.internal.cluster.ClusterGroupAdapter
org.apache.ignite.internal.cluster.ClusterGroupAdapter$AgeProjection
org.apache.ignite.internal.cluster.ClusterGroupAdapter$AttributeFilter
org.apache.ignite.internal.cluster.ClusterGroupAdapter$CachesFilter
org.apache.ignite.internal.cluster.ClusterGroupAdapter$DaemonFilter
org.apache.ignite.internal.cluster.ClusterGroupAdapter$OthersFilter
org.apache.ignite.internal.cluster.ClusterGroupAdapter$StreamersFilter
org.apache.ignite.internal.cluster.ClusterGroupEmptyCheckedException
org.apache.ignite.internal.cluster.ClusterNodeLocalMapImpl
org.apache.ignite.internal.cluster.ClusterTopologyCheckedException
org.apache.ignite.internal.cluster.IgniteClusterAsyncImpl
org.apache.ignite.internal.cluster.IgniteClusterImpl
org.apache.ignite.internal.cluster.IgniteClusterImpl$1
org.apache.ignite.internal.cluster.IgniteKillTask
org.apache.ignite.internal.cluster.IgniteKillTask$IgniteKillJob
org.apache.ignite.internal.compute.ComputeTaskCancelledCheckedException
org.apache.ignite.internal.compute.ComputeTaskTimeoutCheckedException
org.apache.ignite.internal.executor.GridExecutorService
Expand Down
Expand Up @@ -740,8 +740,7 @@ public void testRemoteListenAsyncOrderedMessages() throws Exception {
final CountDownLatch rcvLatch = new CountDownLatch(3);

ignite2.message().remoteListen(S_TOPIC_1, new P2<UUID, Object>() {
@Override
public boolean apply(UUID nodeId, Object msg) {
@Override public boolean apply(UUID nodeId, Object msg) {
try {
log.info("Received new message [msg=" + msg + ", senderNodeId=" + nodeId + ']');

Expand Down

0 comments on commit b5cc14f

Please sign in to comment.