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 @@ -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 @@ -105,20 +105,41 @@ public byte[] nodeFilterBytes() {
return nodeFilterBytes;
}

/** */
public LazyServiceConfiguration nodeFilterBytes(byte[] nodeFilterBytes) {
this.nodeFilterBytes = nodeFilterBytes;

return this;
}

/**
* @return Service bytes.
*/
public byte[] serviceBytes() {
return srvcBytes;
}

/** */
public LazyServiceConfiguration serviceBytes(byte[] srvcBytes) {
this.srvcBytes = srvcBytes;

return this;
}

/**
* @return Service class name.
*/
public String serviceClassName() {
return srvcClsName;
}

/** */
public LazyServiceConfiguration serviceClassName(String srvcClsName) {
this.srvcClsName = srvcClsName;

return this;
}

/** {@inheritDoc} */
@Override public Service getService() {
assert srvc != null : this;
Expand Down Expand Up @@ -150,6 +171,13 @@ public byte[] interceptorBytes() {
return interceptorsBytes;
}

/** */
public LazyServiceConfiguration interceptorBytes(byte[] interceptorsBytes) {
this.interceptorsBytes = interceptorsBytes;

return this;
}

/** {@inheritDoc} */
@Override public boolean equals(Object o) {
if (!(o instanceof LazyServiceConfiguration))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
/*
* 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;

/** 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() {
LazyServiceConfiguration cfg = (LazyServiceConfiguration)new LazyServiceConfiguration()
.setName(name)
.setTotalCount(totalCnt)
.setMaxPerNodeCount(maxPerNodeCnt)
.setCacheName(cacheName)
.setAffinityKey(affKey)
.setStatisticsEnabled(isStatisticsEnabled)
.setLocalStartOrder(locStartOrder);

return cfg.serviceClassName(srvcClsName)
.serviceBytes(srvcBytes)
.nodeFilterBytes(nodeFilterBytes)
.interceptorBytes(interceptorsBytes)
.platformMtdNames(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