Repository: incubator-ignite Updated Branches: refs/heads/ignite-950 8592c8d42 -> 02faa773d
ignite-950: merge from sprint-6 Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/6ec00acb Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/6ec00acb Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/6ec00acb Branch: refs/heads/ignite-950 Commit: 6ec00acbde7b107f74abdcdf6940540d9ddcac00 Parents: 8592c8d Author: Denis Magda <dma...@gridgain.com> Authored: Wed Jun 10 08:55:56 2015 +0300 Committer: Denis Magda <dma...@gridgain.com> Committed: Wed Jun 10 08:55:56 2015 +0300 ---------------------------------------------------------------------- DEVNOTES.txt | 7 +++ .../cloud/TcpDiscoveryCloudIpFinder.java | 25 +++++++--- .../TcpDiscoveryCloudIpFinderSelfTest.java | 3 +- .../internal/interop/InteropIgnition.java | 52 +++++++++++++++++++- .../internal/interop/InteropProcessor.java | 8 +++ .../optimized/OptimizedObjectReader.java | 25 ---------- 6 files changed, 83 insertions(+), 37 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6ec00acb/DEVNOTES.txt ---------------------------------------------------------------------- diff --git a/DEVNOTES.txt b/DEVNOTES.txt index 1562dc4..8f1730c 100644 --- a/DEVNOTES.txt +++ b/DEVNOTES.txt @@ -69,6 +69,13 @@ To test compliance with JCache TCK use: mvn test -P-release,jcache-tck -pl :ignite-core -am +Run tests +========== +To run tests locally use: + +mvn clean test -U -Plgpl,examples,-clean-libs,-release -Dmaven.test.failure.ignore=true -DfailIfNoTests=false -Dtest=%TEST_PATTERN% + +For example, %TEST_PATTERN% can be 'org.apache.ignite.testsuites.IgniteBasicTestSuite' or 'GridCacheLocalAtomicFullApiSelfTest#testGet' Apache RAT Instructions ======================= http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6ec00acb/modules/cloud/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/cloud/TcpDiscoveryCloudIpFinder.java ---------------------------------------------------------------------- diff --git a/modules/cloud/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/cloud/TcpDiscoveryCloudIpFinder.java b/modules/cloud/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/cloud/TcpDiscoveryCloudIpFinder.java index 2637742..7555b16 100644 --- a/modules/cloud/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/cloud/TcpDiscoveryCloudIpFinder.java +++ b/modules/cloud/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/cloud/TcpDiscoveryCloudIpFinder.java @@ -30,6 +30,7 @@ import org.jclouds.*; import org.jclouds.compute.*; import org.jclouds.compute.domain.*; import org.jclouds.domain.*; +import org.jclouds.googlecloud.*; import org.jclouds.location.reference.*; import java.io.*; @@ -97,7 +98,7 @@ import java.util.concurrent.atomic.*; * <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.cloud.TcpDiscoveryCloudIpFinder"/> * <property name="provider" value="google-compute-engine"/> * <property name="identity" value="your_service_account_email"/> - * <property name="credentialPath" value="path_to_pem_file"/> + * <property name="credentialPath" value="path_to_json_key"/> * <property name="zones"> * <list> * <value>us-central1-a</value> @@ -253,8 +254,7 @@ public class TcpDiscoveryCloudIpFinder extends TcpDiscoveryIpFinderAdapter { /** * Sets the path to a credential that is used during authentication on the cloud. * - * This method should be used when an access key or private key is stored in a plain or PEM file without - * a passphrase. + * This method should be used when an access key or private key is stored in a file. * Content of the file, referred by @{code credentialPath}, is fully read and used as a access key or private key * during authentication. * @@ -322,7 +322,7 @@ public class TcpDiscoveryCloudIpFinder extends TcpDiscoveryIpFinderAdapter { throw new IgniteSpiException("Both credential and credentialPath are set. Use only one method."); if (credentialPath != null) - credential = getPrivateKeyFromFile(); + credential = getCredentialFromFile(); try { ContextBuilder ctxBuilder = ContextBuilder.newBuilder(provider); @@ -398,13 +398,22 @@ public class TcpDiscoveryCloudIpFinder extends TcpDiscoveryIpFinderAdapter { } /** - * Retrieves a private key from the secrets file. + * Reads credential info from {@link #credentialPath} and returns in a string format. * - * @return Private key + * @return Credential in {@code String} representation. + * @throws IgniteSpiException In case of error. */ - private String getPrivateKeyFromFile() throws IgniteSpiException { + private String getCredentialFromFile() throws IgniteSpiException { try { - return Files.toString(new File(credentialPath), Charsets.UTF_8); + String fileContents = Files.toString(new File(credentialPath), Charsets.UTF_8); + + if (provider.equals("google-compute-engine")) { + Supplier<Credentials> credentialSupplier = new GoogleCredentialsFromJson(fileContents); + + return credentialSupplier.get().credential; + } + + return fileContents; } catch (IOException e) { throw new IgniteSpiException("Failed to retrieve the private key from the file: " + credentialPath, e); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6ec00acb/modules/cloud/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/cloud/TcpDiscoveryCloudIpFinderSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/cloud/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/cloud/TcpDiscoveryCloudIpFinderSelfTest.java b/modules/cloud/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/cloud/TcpDiscoveryCloudIpFinderSelfTest.java index aba0760..d1d945f 100644 --- a/modules/cloud/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/cloud/TcpDiscoveryCloudIpFinderSelfTest.java +++ b/modules/cloud/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/cloud/TcpDiscoveryCloudIpFinderSelfTest.java @@ -101,9 +101,8 @@ public class TcpDiscoveryCloudIpFinderSelfTest extends if (provider.equals("google-compute-engine")) ipFinder.setCredentialPath(IgniteCloudTestSuite.getSecretKey(provider)); - else { + else ipFinder.setCredential(IgniteCloudTestSuite.getSecretKey(provider)); - } Collection<InetSocketAddress> addresses = ipFinder.getRegisteredAddresses(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6ec00acb/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropIgnition.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropIgnition.java b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropIgnition.java index 3ccd361..d8cc276 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropIgnition.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropIgnition.java @@ -35,6 +35,9 @@ import java.util.*; */ @SuppressWarnings("UnusedDeclaration") public class InteropIgnition { + /** Map with active instances. */ + private static final HashMap<String, InteropProcessor> instances = new HashMap<>(); + /** * Start Ignite node in interop mode. * @@ -44,8 +47,8 @@ public class InteropIgnition { * @param envPtr Environment pointer. * @return Ignite instance. */ - public static InteropProcessor start(@Nullable String springCfgPath, @Nullable String gridName, int factoryId, - long envPtr) { + public static synchronized InteropProcessor start(@Nullable String springCfgPath, @Nullable String gridName, + int factoryId, long envPtr) { IgniteConfiguration cfg = configuration(springCfgPath); if (gridName != null) @@ -57,10 +60,55 @@ public class InteropIgnition { trackFinalization(proc); + InteropProcessor old = instances.put(gridName, proc); + + assert old == null; + return proc; } /** + * Get instance by environment pointer. + * + * @param gridName Grid name. + * @return Instance or {@code null} if it doesn't exists (never started or stopped). + */ + @Nullable public static synchronized InteropProcessor instance(@Nullable String gridName) { + return instances.get(gridName); + } + + /** + * Stop single instance. + * + * @param gridName Grid name, + * @param cancel Cancel flag. + * @return {@code True} if instance was found and stopped. + */ + public static synchronized boolean stop(@Nullable String gridName, boolean cancel) { + if (Ignition.stop(gridName, cancel)) { + InteropProcessor old = instances.remove(gridName); + + assert old != null; + + return true; + } + else + return false; + } + + /** + * Stop all instances. + * + * @param cancel Cancel flag. + */ + public static synchronized void stopAll(boolean cancel) { + for (InteropProcessor proc : instances.values()) + Ignition.stop(proc.ignite().name(), cancel); + + instances.clear(); + } + + /** * Create configuration. * * @param springCfgPath Path to Spring XML. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6ec00acb/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropProcessor.java index aa4f877..325a464 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropProcessor.java @@ -17,6 +17,7 @@ package org.apache.ignite.internal.interop; +import org.apache.ignite.*; import org.jetbrains.annotations.*; /** @@ -24,6 +25,13 @@ import org.jetbrains.annotations.*; */ public interface InteropProcessor { /** + * Get owning Ignite instance. + * + * @return Ignite instance. + */ + public Ignite ignite(); + + /** * Get stop runnable to perform cleanup when interop is not longer used. * <p/> * <b>NOTE!</b> This runnable is called when current instance of interop processor is eligible for garbage http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6ec00acb/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectReader.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectReader.java b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectReader.java deleted file mode 100644 index 9db2986..0000000 --- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectReader.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.marshaller.optimized; - -/** - * TODO: - */ -public class OptimizedObjectReader { - -}