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 @@ -2153,4 +2153,18 @@ public static <T> Collection<T> emptyIfNull(@Nullable Collection<T> col) {
public static <K, V> Map<K, V> emptyIfNull(@Nullable Map<K, V> map) {
return map == null ? Collections.emptyMap() : map;
}

/**
* @param arr Array.
* @param el Element.
* @return Element index or {@code -1} if not found.
*/
public static <T> int indexOf(T[] arr, T el) {
for (int i = 0; i < arr.length; i++) {
if (Objects.equals(arr[i], el))
return i;
}

return -1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.ignite.util.CacheMetricsCommandTest;
import org.apache.ignite.util.CdcCommandTest;
import org.apache.ignite.util.CdcResendCommandTest;
import org.apache.ignite.util.GridCommandHandlerClassPathTest;
import org.apache.ignite.util.GridCommandHandlerConsistencyBinaryTest;
import org.apache.ignite.util.GridCommandHandlerConsistencyCountersTest;
import org.apache.ignite.util.GridCommandHandlerConsistencyRepairCorrectnessAtomicTest;
Expand Down Expand Up @@ -77,7 +78,8 @@

SecurityCommandHandlerPermissionsTest.class,

IdleVerifyDumpTest.class
IdleVerifyDumpTest.class,
GridCommandHandlerClassPathTest.class
})
public class IgniteControlUtilityTestSuite2 {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* 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.util;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.stream.Collectors;
import org.junit.Test;

import static org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_OK;

/**
* Test for --classpath command.
*/
public class GridCommandHandlerClassPathTest extends GridCommandHandlerAbstractTest {
/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
cleanPersistenceDir();

startGrids(2);

super.beforeTestsStarted();
}

/** Tests --create command. */
@Test
public void testCreate() throws Exception {
String jars = Files.list(Path.of(getClass().getClassLoader().getResource(".").getPath() + "../"))
.map(Path::toAbsolutePath)
.map(Path::toString)
.filter(f -> f.endsWith("jar"))
.collect(Collectors.joining(","));

Path dir = Path.of(getClass().getClassLoader().getResource(".").getPath() + "../../../core/target");

System.out.println("dir = " + dir);

String coreJars = Files.list(dir)
.map(Path::toAbsolutePath)
.map(Path::toString)
.filter(f -> f.endsWith("jar"))
.collect(Collectors.joining(","));

jars += "," + coreJars;

injectTestSystemOut();

final TestCommandHandler hnd = newCommandHandler(createTestLogger());

assertEquals(EXIT_CODE_OK, execute(hnd, "--class-path", "create", "--name", "mysuperapp", "--files", jars));

String outStr = testOut.toString();

stopAllGrids();

System.out.println(outStr);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.ignite.internal.binary.BinaryMarshaller;
import org.apache.ignite.internal.cache.query.index.IndexProcessor;
import org.apache.ignite.internal.cache.transform.CacheObjectTransformerProcessor;
import org.apache.ignite.internal.classpath.ClassPathProcessor;
import org.apache.ignite.internal.managers.checkpoint.GridCheckpointManager;
import org.apache.ignite.internal.managers.collision.GridCollisionManager;
import org.apache.ignite.internal.managers.communication.GridIoManager;
Expand Down Expand Up @@ -648,6 +649,11 @@ public interface GridKernalContext extends Iterable<GridComponent> {
*/
public RollingUpgradeProcessor rollingUpgrade();

/**
* @return Class path processor.
*/
public ClassPathProcessor classPath();

/**
* Executor that is in charge of processing user async continuations.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.apache.ignite.internal.binary.GridBinaryMarshaller;
import org.apache.ignite.internal.cache.query.index.IndexProcessor;
import org.apache.ignite.internal.cache.transform.CacheObjectTransformerProcessor;
import org.apache.ignite.internal.classpath.ClassPathProcessor;
import org.apache.ignite.internal.maintenance.MaintenanceProcessor;
import org.apache.ignite.internal.managers.checkpoint.GridCheckpointManager;
import org.apache.ignite.internal.managers.collision.GridCollisionManager;
Expand Down Expand Up @@ -367,6 +368,10 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
@GridToStringExclude
private RollingUpgradeProcessor rollUpProc;

/** Classpath processor. */
@GridToStringExclude
private ClassPathProcessor classPathProc;

/** */
private Thread.UncaughtExceptionHandler hnd;

Expand Down Expand Up @@ -603,6 +608,8 @@ else if (comp instanceof PerformanceStatisticsProcessor)
perfStatProc = (PerformanceStatisticsProcessor)comp;
else if (comp instanceof RollingUpgradeProcessor)
rollUpProc = (RollingUpgradeProcessor)comp;
else if (comp instanceof ClassPathProcessor)
classPathProc = (ClassPathProcessor)comp;
else if (comp instanceof IndexProcessor)
indexProc = (IndexProcessor)comp;
else if (!(comp instanceof DiscoveryNodeValidationProcessor
Expand Down Expand Up @@ -1117,6 +1124,11 @@ public void recoveryMode(boolean recoveryMode) {
return rollUpProc;
}

/** {@inheritDoc} */
@Override public ClassPathProcessor classPath() {
return classPathProc;
}

/** {@inheritDoc} */
@Override public Executor getAsyncContinuationExecutor() {
return config().getAsyncContinuationExecutor() == null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.cache.query.index.IndexProcessor;
import org.apache.ignite.internal.cache.transform.CacheObjectTransformerProcessor;
import org.apache.ignite.internal.classpath.ClassPathProcessor;
import org.apache.ignite.internal.cluster.ClusterGroupAdapter;
import org.apache.ignite.internal.cluster.IgniteClusterEx;
import org.apache.ignite.internal.maintenance.MaintenanceProcessor;
Expand Down Expand Up @@ -1018,6 +1019,7 @@ public void start(
// Start the encryption manager after assigning the discovery manager to context, so it will be
// able to register custom event listener.
startManager(new GridEncryptionManager(ctx));
startProcessor(new ClassPathProcessor(ctx));

startProcessor(new PdsConsistentIdProcessor(ctx));

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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.classpath;

import java.io.Serializable;
import java.util.UUID;
import org.apache.ignite.internal.util.distributed.DistributedProcess;

/**
* Class path deploy to all request for {@link DistributedProcess} initiate message.
*/
public class ClassPathDeployToAllRequest implements Serializable {
/** Serial version uid. */
private static final long serialVersionUID = 0L;

/** Ignite class path id. */
final UUID icpId;

/** */
public ClassPathDeployToAllRequest(UUID icpId) {
this.icpId = icpId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* 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.classpath;

import java.io.Serializable;
import org.apache.ignite.internal.util.distributed.DistributedProcess;

/**
* Class path deploy to all response for {@link DistributedProcess} initiate message.
*/
public class ClassPathDeployToAllResponse implements Serializable {
}
Loading
Loading