Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,11 @@
import org.apache.ignite.internal.processors.service.ServiceClusterDeploymentResultBatch;
import org.apache.ignite.internal.processors.service.ServiceDeploymentProcessId;
import org.apache.ignite.internal.processors.service.ServiceDeploymentRequest;
import org.apache.ignite.internal.processors.service.ServiceInfo;
import org.apache.ignite.internal.processors.service.ServiceProcessorCommonDiscoveryData;
import org.apache.ignite.internal.processors.service.ServiceSingleNodeDeploymentResult;
import org.apache.ignite.internal.processors.service.ServiceSingleNodeDeploymentResultBatch;
import org.apache.ignite.internal.processors.service.ServiceTopology;
import org.apache.ignite.internal.processors.service.ServiceUndeploymentRequest;
import org.apache.ignite.internal.util.GridByteArrayList;
import org.apache.ignite.internal.util.GridIntList;
Expand Down Expand Up @@ -425,6 +428,9 @@ public CoreMessagesProvider(Marshaller dfltMarsh, Marshaller schemaAwareMarsh, C
withNoSchema(ServiceClusterDeploymentResultBatch.class);
withNoSchema(ServiceChangeBatchRequest.class);
withNoSchema(ServiceSingleNodeDeploymentResultBatch.class);
withNoSchema(ServiceProcessorCommonDiscoveryData.class);
withNoSchema(ServiceInfo.class);
withNoSchema(ServiceTopology.class);

// [6500 - 6700]: DiscoveryCustomMessage
msgIdx = 6500;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@

import java.util.Map;
import java.util.UUID;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.MarshallableMessage;
import org.apache.ignite.internal.Order;
import org.apache.ignite.internal.managers.deployment.GridDeployment;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.plugin.extensions.communication.MessageFactory;
import org.apache.ignite.services.Service;
import org.apache.ignite.services.ServiceDescriptor;
import org.jetbrains.annotations.NotNull;
Expand All @@ -35,32 +41,45 @@
/**
* Service's information container.
*/
public class ServiceInfo implements ServiceDescriptor {
public class ServiceInfo implements ServiceDescriptor, MarshallableMessage {
/** */
private static final long serialVersionUID = 0L;

/** Context. */
private transient volatile GridKernalContext ctx;

/** Origin node ID. */
private final UUID originNodeId;
@Order(0)
UUID originNodeId;

/** Service id. */
private final IgniteUuid srvcId;
@Order(1)
IgniteUuid srvcId;

/** Service configuration. */
private final LazyServiceConfiguration cfg;
private LazyServiceConfiguration cfg;

/** Serialized {@link #cfg}.*/
@Order(2)
transient byte[] cfgBytes;

/** Statically configured flag. */
private final boolean staticCfg;
@Order(3)
boolean staticCfg;

/** Topology snapshot. */
@Order(4)
@GridToStringInclude
private volatile ServiceTopology top = EMPTY;
volatile ServiceTopology top = EMPTY;

/** Service class. */
private transient volatile Class<? extends Service> srvcCls;

/** Default constructor for {@link MessageFactory}. */
public ServiceInfo() {
// No-op.
}

/**
* @param originNodeId Initiating node id.
* @param srvcId Service id.
Expand Down Expand Up @@ -199,4 +218,19 @@ public IgniteUuid serviceId() {
@Override public String toString() {
return S.toString(ServiceInfo.class, this);
}

/** {@inheritDoc} */
@Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException {
if (cfg != null)
cfgBytes = U.marshal(marsh, cfg);
}

/** {@inheritDoc} */
@Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException {
if (cfgBytes != null) {
cfg = U.unmarshal(marsh, cfgBytes, clsLdr);

cfgBytes = null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,26 @@

package org.apache.ignite.internal.processors.service;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.apache.ignite.internal.Order;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.plugin.extensions.communication.MessageFactory;
import org.jetbrains.annotations.NotNull;

/**
* Initial data container to be sent to newly joining node for initialization of {@link IgniteServiceProcessor}.
*/
class ServiceProcessorCommonDiscoveryData implements Serializable {
/** */
private static final long serialVersionUID = 0L;

/** Initial data container to be sent to newly joining node for initialization of {@link IgniteServiceProcessor}. */
public class ServiceProcessorCommonDiscoveryData implements Message {
/** Clusters registered services descriptors. */
private final ArrayList<ServiceInfo> registeredServices;
@Order(0)
List<ServiceInfo> registeredServices;

/**
* @param registeredServices Clusters registered services descriptors.
*/
public ServiceProcessorCommonDiscoveryData(@NotNull ArrayList<ServiceInfo> registeredServices) {
/** Default constructor for {@link MessageFactory}. */
public ServiceProcessorCommonDiscoveryData() {
// No-op.
}

/** @param registeredServices Clusters registered services descriptors. */
public ServiceProcessorCommonDiscoveryData(@NotNull List<ServiceInfo> registeredServices) {
this.registeredServices = registeredServices;
}

Expand All @@ -44,7 +45,7 @@ public ServiceProcessorCommonDiscoveryData(@NotNull ArrayList<ServiceInfo> regis
*
* @return Registered services descriptors.
*/
public ArrayList<ServiceInfo> registeredServices() {
public List<ServiceInfo> registeredServices() {
return registeredServices;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,37 @@
import java.util.Collections;
import java.util.Map;
import java.util.UUID;
import org.apache.ignite.internal.Order;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.plugin.extensions.communication.MessageFactory;

/** */
public class ServiceTopology implements Serializable {
public class ServiceTopology implements Serializable, Message {
/** Serial version uid. */
private static final long serialVersionUID = 0L;

/** Empty service topology instance. */
public static final ServiceTopology EMPTY = new ServiceTopology();
public static final ServiceTopology EMPTY = empty();

/** Topology snapshot. */
@Order(0)
@GridToStringInclude
private final Map<UUID, Integer> snapshot;
Map<UUID, Integer> snapshot;

/**
* Whether topology is transitional. Nodes may leave the cluster while the service topology is being recalculated.
* In this case, the resulting service topology may be incomplete. We consider the mentioned service topology
* transitional and expect it to be recalculated soon.
*/
@Order(1)
@GridToStringInclude
private final boolean isTransitional;
boolean isTransitional;

/** */
private ServiceTopology() {
snapshot = Collections.emptyMap();
isTransitional = true;
/** Default constructor for {@link MessageFactory}. */
public ServiceTopology() {
// No-op.
}

/** */
Expand Down Expand Up @@ -85,4 +89,14 @@ public boolean containsNode(UUID nodeId) {
@Override public String toString() {
return S.toString(ServiceTopology.class, this);
}

/** */
private static ServiceTopology empty() {
ServiceTopology top = new ServiceTopology();

top.snapshot = Collections.emptyMap();
top.isTransitional = true;

return top;
}
}
Loading