Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,18 @@
import org.apache.ignite.internal.processors.rollingupgrade.feature.IgniteFeatureSet;
import org.apache.ignite.internal.processors.rollingupgrade.feature.IgnitePluginFeatureSet;
import org.apache.ignite.internal.processors.security.SecurityContextWrapper;
import org.apache.ignite.internal.processors.service.LazyServiceConfigurationMessage;
import org.apache.ignite.internal.processors.service.ServiceChangeBatchRequest;
import org.apache.ignite.internal.processors.service.ServiceClusterDeploymentResult;
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.ServiceProcessorJoinNodeDiscoveryData;
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 @@ -431,6 +436,11 @@ public CoreMessagesProvider(Marshaller dfltMarsh, Marshaller schemaAwareMarsh, C
withNoSchema(ServiceClusterDeploymentResultBatch.class);
withNoSchema(ServiceChangeBatchRequest.class);
withNoSchema(ServiceSingleNodeDeploymentResultBatch.class);
withNoSchema(ServiceProcessorCommonDiscoveryData.class);
withNoSchema(ServiceProcessorJoinNodeDiscoveryData.class);
withNoSchema(ServiceInfo.class);
withNoSchema(ServiceTopology.class);
withNoSchema(LazyServiceConfigurationMessage.class);

// [6500 - 6700]: DiscoveryCustomMessage
msgIdx = 6500;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1805,7 +1805,7 @@ else if (req instanceof ServiceUndeploymentRequest)
LazyServiceConfiguration cfg = ((ServiceDeploymentRequest)req).configuration();

if (ctx.security().enabled())
err = checkPermissions(((ServiceDeploymentRequest)req).configuration().getName(), SERVICE_DEPLOY);
err = checkPermissions(cfg.getName(), SERVICE_DEPLOY);

if (err == null) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,38 @@ public LazyServiceConfiguration(
locStartOrder = cfg.getLocalStartOrder();
}

/**
* Constructor for deserialization from network message (when service/filter/interceptors are only available as bytes).
*
* @param cfg Configuration with scalar fields (name, counts, cache, etc.).
* @param srvcClsName Service class name.
* @param srvcBytes Marshalled service.
* @param nodeFilterBytes Marshalled node filter.
* @param interceptorsBytes Marshalled interceptors.
* @param platformMtdNames Platform method names for statistics.
*/
LazyServiceConfiguration(
Comment thread
wernerdv marked this conversation as resolved.
Outdated
ServiceConfiguration cfg,
String srvcClsName,
byte[] srvcBytes,
byte[] nodeFilterBytes,
byte[] interceptorsBytes,
String[] platformMtdNames
) {
name = cfg.getName();
totalCnt = cfg.getTotalCount();
maxPerNodeCnt = cfg.getMaxPerNodeCount();
cacheName = cfg.getCacheName();
affKey = cfg.getAffinityKey();
isStatisticsEnabled = cfg.isStatisticsEnabled();
locStartOrder = cfg.getLocalStartOrder();
this.srvcClsName = srvcClsName;
this.srvcBytes = srvcBytes;
this.nodeFilterBytes = nodeFilterBytes;
this.interceptorsBytes = interceptorsBytes;
this.platformMtdNames = platformMtdNames;
}

/**
* @return Node filter bytes.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

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

import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.MarshallableMessage;
import org.apache.ignite.internal.Order;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.plugin.extensions.communication.MessageFactory;
import org.apache.ignite.services.ServiceConfiguration;

/** Message for {@link LazyServiceConfiguration}. */
public class LazyServiceConfigurationMessage implements MarshallableMessage {
/** Service name. */
@Order(0)
String name;

/** Total count. */
@Order(1)
int totalCnt;

/** Max per-node count. */
@Order(2)
int maxPerNodeCnt;

/** Cache name. */
@Order(3)
String cacheName;

/** Affinity key. */
private Object affKey;

/** Serialized {@link #affKey}. */
@Order(4)
byte[] affKeyBytes;

/** Enables or disables service statistics. */
@Order(5)
boolean isStatisticsEnabled;

/** Node local start order. */
@Order(6)
int locStartOrder;

/** Service class name. */
@Order(7)
String srvcClsName;

/** Serialized service. */
@Order(8)
byte[] srvcBytes;

/** Serialized node filter. */
@Order(9)
byte[] nodeFilterBytes;

/** Serialized interceptors. */
@Order(10)
byte[] interceptorsBytes;

/** Names of platform service methods to build service statistics. */
@Order(11)
@GridToStringExclude
String[] platformMtdNames;

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

/** @param cfg Service config. */
public LazyServiceConfigurationMessage(LazyServiceConfiguration cfg) {
assert cfg != null : "LazyServiceConfiguration is null";

name = cfg.getName();
totalCnt = cfg.getTotalCount();
maxPerNodeCnt = cfg.getMaxPerNodeCount();
cacheName = cfg.getCacheName();
affKey = cfg.getAffinityKey();
isStatisticsEnabled = cfg.isStatisticsEnabled();
locStartOrder = cfg.getLocalStartOrder();
srvcClsName = cfg.serviceClassName();
srvcBytes = cfg.serviceBytes();
nodeFilterBytes = cfg.nodeFilterBytes();
interceptorsBytes = cfg.interceptorBytes();
platformMtdNames = cfg.platformMtdNames();
}

/** @return Service configuration. */
public LazyServiceConfiguration toConfiguration() {
ServiceConfiguration cfg = new ServiceConfiguration()
Comment thread
wernerdv marked this conversation as resolved.
Outdated
.setName(name)
.setTotalCount(totalCnt)
.setMaxPerNodeCount(maxPerNodeCnt)
.setCacheName(cacheName)
.setAffinityKey(affKey)
.setStatisticsEnabled(isStatisticsEnabled)
.setLocalStartOrder(locStartOrder);

return new LazyServiceConfiguration(cfg, srvcClsName, srvcBytes, nodeFilterBytes, interceptorsBytes, platformMtdNames);
}

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

/** {@inheritDoc} */
@Override public void finishUnmarshal(Marshaller marsh, ClassLoader clsLdr) throws IgniteCheckedException {
if (!F.isEmpty(affKeyBytes)) {
affKey = U.unmarshal(marsh, affKeyBytes, clsLdr);

affKeyBytes = null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,24 @@

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

import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.MarshallableMessage;
import org.apache.ignite.internal.Order;
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.jetbrains.annotations.NotNull;

/**
* Service deployment request.
*/
public class ServiceDeploymentRequest extends ServiceChangeAbstractRequest implements MarshallableMessage {
/** Service deployment request. */
public class ServiceDeploymentRequest extends ServiceChangeAbstractRequest {
/** Service configuration. */
private LazyServiceConfiguration cfg;

/** JDK serialization for {@link #cfg}. */
/** Service configuration message. */
@Order(0)
byte[] cfgBytes;
LazyServiceConfigurationMessage cfgMsg;

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

/**
Expand All @@ -49,25 +44,16 @@ public ServiceDeploymentRequest() {
public ServiceDeploymentRequest(@NotNull IgniteUuid srvcId, @NotNull LazyServiceConfiguration cfg) {
this.srvcId = srvcId;
this.cfg = cfg;
}

/**
* @return Service configuration.
*/
public LazyServiceConfiguration configuration() {
return cfg;
cfgMsg = new LazyServiceConfigurationMessage(cfg);
}

/** {@inheritDoc} */
@Override public void prepareMarshal(Marshaller marsh) throws IgniteCheckedException {
if (cfg != null)
cfgBytes = U.marshal(marsh, cfg);
}
/** @return Service configuration. */
public LazyServiceConfiguration configuration() {
if (cfg == null && cfgMsg != null)
cfg = cfgMsg.toConfiguration();

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

/** {@inheritDoc} */
Expand Down
Loading
Loading