# ignite-63
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/4187cb06 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/4187cb06 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/4187cb06 Branch: refs/heads/ignite-63 Commit: 4187cb06cadcb47b0faf0e49a13b56e905a86cf6 Parents: 0204d75 Author: sboikov <sboi...@gridgain.com> Authored: Fri Jan 23 11:59:19 2015 +0300 Committer: sboikov <sboi...@gridgain.com> Committed: Fri Jan 23 11:59:19 2015 +0300 ---------------------------------------------------------------------- .../org/apache/ignite/internal/GridKernal.java | 4 +- .../ignite/internal/GridKernalContext.java | 4 +- .../ignite/internal/GridKernalContextImpl.java | 16 +- .../ignite/internal/IgniteComponentType.java | 16 +- .../processors/cache/GridCacheContext.java | 6 +- .../processors/cache/GridCacheProcessor.java | 2 +- .../cache/jta/CacheJtaManagerAdapter.java | 50 + .../cache/jta/CacheNoopJtaManager.java | 42 + .../cache/jta/GridCacheJtaManagerAdapter.java | 50 - .../cache/jta/GridCacheNoopJtaManager.java | 42 - .../email/GridEmailProcessorAdapter.java | 85 - .../email/GridNoopEmailProcessor.java | 56 - .../email/IgniteEmailProcessorAdapter.java | 85 + .../email/IgniteNoopEmailProcessor.java | 56 + .../schedule/GridNoopScheduleProcessor.java | 54 - .../schedule/GridScheduleProcessorAdapter.java | 53 - .../schedule/IgniteNoopScheduleProcessor.java | 54 + .../IgniteScheduleProcessorAdapter.java | 53 + .../util/nodestart/GridSshProcessor.java | 34 - .../util/nodestart/IgniteSshProcessor.java | 34 + .../loadtests/hashmap/GridCacheTestContext.java | 2 +- .../processors/email/GridEmailProcessor.java | 297 --- .../processors/email/IgniteEmailProcessor.java | 297 +++ .../processors/query/h2/GridH2Indexing.java | 2003 ------------------ .../processors/query/h2/IgniteH2Indexing.java | 2003 ++++++++++++++++++ .../query/h2/opt/GridH2RowDescriptor.java | 2 +- .../query/h2/opt/GridLuceneIndex.java | 2 +- .../GridCacheQueryMultiThreadedSelfTest.java | 2 +- .../query/h2/GridH2IndexRebuildTest.java | 2 +- .../query/h2/GridH2IndexingOffheapSelfTest.java | 4 +- .../h2/GridIndexingSpiAbstractSelfTest.java | 14 +- .../processors/cache/jta/CacheJtaManager.java | 113 + .../cache/jta/GridCacheJtaManager.java | 113 - .../schedule/GridScheduleProcessor.java | 130 -- .../schedule/IgniteScheduleProcessor.java | 130 ++ .../processors/schedule/ScheduleFutureImpl.java | 4 +- .../util/nodestart/GridSshProcessorImpl.java | 28 - .../util/nodestart/IgniteSshProcessorImpl.java | 28 + 38 files changed, 2985 insertions(+), 2985 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4187cb06/modules/core/src/main/java/org/apache/ignite/internal/GridKernal.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernal.java index 7358106..681009d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernal.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernal.java @@ -1900,7 +1900,7 @@ public class GridKernal extends ClusterGroupAdapter implements GridEx, IgniteMBe notifyLifecycleBeansEx(LifecycleEventType.BEFORE_GRID_STOP); } - GridEmailProcessorAdapter email = ctx.email(); + IgniteEmailProcessorAdapter email = ctx.email(); List<GridComponent> comps = ctx.components(); @@ -2672,7 +2672,7 @@ public class GridKernal extends ClusterGroupAdapter implements GridEx, IgniteMBe guard(); try { - GridSshProcessor sshProcessor = IgniteComponentType.SSH.create(false); + IgniteSshProcessor sshProcessor = IgniteComponentType.SSH.create(false); Map<String, Collection<GridRemoteStartSpecification>> specsMap = specifications(hosts, dflts); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4187cb06/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java index 282ace5..21ba6d9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java @@ -250,14 +250,14 @@ public interface GridKernalContext extends Iterable<GridComponent> { * * @return Email processor. */ - public GridEmailProcessorAdapter email(); + public IgniteEmailProcessorAdapter email(); /** * Gets schedule processor. * * @return Schedule processor. */ - public GridScheduleProcessorAdapter schedule(); + public IgniteScheduleProcessorAdapter schedule(); /** * Gets REST processor. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4187cb06/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java index e9e4599..4ec1bcc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java @@ -199,11 +199,11 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable /** */ @GridToStringInclude - private GridEmailProcessorAdapter emailProc; + private IgniteEmailProcessorAdapter emailProc; /** */ @GridToStringInclude - private GridScheduleProcessorAdapter scheduleProc; + private IgniteScheduleProcessorAdapter scheduleProc; /** */ @GridToStringInclude @@ -414,14 +414,14 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable sesProc = (GridTaskSessionProcessor)comp; else if (comp instanceof GridPortProcessor) portProc = (GridPortProcessor)comp; - else if (comp instanceof GridEmailProcessorAdapter) - emailProc = (GridEmailProcessorAdapter)comp; + else if (comp instanceof IgniteEmailProcessorAdapter) + emailProc = (IgniteEmailProcessorAdapter)comp; else if (comp instanceof GridClosureProcessor) closProc = (GridClosureProcessor)comp; else if (comp instanceof GridServiceProcessor) svcProc = (GridServiceProcessor)comp; - else if (comp instanceof GridScheduleProcessorAdapter) - scheduleProc = (GridScheduleProcessorAdapter)comp; + else if (comp instanceof IgniteScheduleProcessorAdapter) + scheduleProc = (IgniteScheduleProcessorAdapter)comp; else if (comp instanceof GridSegmentationProcessor) segProc = (GridSegmentationProcessor)comp; else if (comp instanceof GridAffinityProcessor) @@ -561,7 +561,7 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable } /** {@inheritDoc} */ - @Override public GridEmailProcessorAdapter email() { + @Override public IgniteEmailProcessorAdapter email() { return emailProc; } @@ -571,7 +571,7 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable } /** {@inheritDoc} */ - @Override public GridScheduleProcessorAdapter schedule() { + @Override public IgniteScheduleProcessorAdapter schedule() { return scheduleProc; } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4187cb06/modules/core/src/main/java/org/apache/ignite/internal/IgniteComponentType.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteComponentType.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteComponentType.java index 1e1fcc3..0d66c93 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteComponentType.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteComponentType.java @@ -57,35 +57,35 @@ public enum IgniteComponentType { /** Indexing. */ INDEXING( null, - "org.apache.ignite.internal.processors.query.h2.GridH2Indexing", + "org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing", "ignite-indexing" ), /** Nodes starting using SSH. */ SSH( null, - "org.apache.ignite.internal.util.nodestart.GridSshProcessorImpl", + "org.apache.ignite.internal.util.nodestart.IgniteSshProcessorImpl", "ignite-ssh" ), /** Email sending. */ EMAIL( - "org.apache.ignite.internal.processors.email.GridNoopEmailProcessor", - "org.apache.ignite.internal.processors.email.GridEmailProcessor", + "org.apache.ignite.internal.processors.email.IgniteNoopEmailProcessor", + "org.apache.ignite.internal.processors.email.IgniteEmailProcessor", "ignite-email" ), /** Integration of cache transactions with JTA. */ JTA( - "org.apache.ignite.internal.processors.cache.jta.GridCacheNoopJtaManager", - "org.apache.ignite.internal.processors.cache.jta.GridCacheJtaManager", + "org.apache.ignite.internal.processors.cache.jta.CacheNoopJtaManager", + "org.apache.ignite.internal.processors.cache.jta.CacheJtaManager", "ignite-jta" ), /** Cron-based scheduling, see {@link org.apache.ignite.IgniteScheduler}. */ SCHEDULE( - "org.apache.ignite.internal.processors.schedule.GridNoopScheduleProcessor", - "org.apache.ignite.internal.processors.schedule.GridScheduleProcessor", + "org.apache.ignite.internal.processors.schedule.IgniteNoopScheduleProcessor", + "org.apache.ignite.internal.processors.schedule.IgniteScheduleProcessor", "ignite-schedule" ); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4187cb06/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java index fcad1e2..8d5c54d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java @@ -130,7 +130,7 @@ public class GridCacheContext<K, V> implements Externalizable { private GridCacheDrManager<K, V> drMgr; /** JTA manager. */ - private GridCacheJtaManagerAdapter<K, V> jtaMgr; + private CacheJtaManagerAdapter<K, V> jtaMgr; /** Managers. */ private List<GridCacheManager<K, V>> mgrs = new LinkedList<>(); @@ -230,7 +230,7 @@ public class GridCacheContext<K, V> implements Externalizable { GridCacheDataStructuresManager<K, V> dataStructuresMgr, GridCacheTtlManager<K, V> ttlMgr, GridCacheDrManager<K, V> drMgr, - GridCacheJtaManagerAdapter<K, V> jtaMgr) { + CacheJtaManagerAdapter<K, V> jtaMgr) { assert ctx != null; assert sharedCtx != null; assert cacheCfg != null; @@ -895,7 +895,7 @@ public class GridCacheContext<K, V> implements Externalizable { /** * @return JTA manager. */ - public GridCacheJtaManagerAdapter<K, V> jta() { + public CacheJtaManagerAdapter<K, V> jta() { return jtaMgr; } /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4187cb06/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java index 98f8cae..dc31ae8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java @@ -608,7 +608,7 @@ public class GridCacheProcessor extends GridProcessorAdapter { validate(ctx.config(), cfg, cfgStore); - GridCacheJtaManagerAdapter jta = JTA.create(cfg.getTransactionManagerLookupClassName() == null); + CacheJtaManagerAdapter jta = JTA.create(cfg.getTransactionManagerLookupClassName() == null); jta.createTmLookup(cfg); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4187cb06/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaManagerAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaManagerAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaManagerAdapter.java new file mode 100644 index 0000000..b2f532c --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaManagerAdapter.java @@ -0,0 +1,50 @@ +/* + * 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.cache.jta; + +import org.apache.ignite.*; +import org.apache.ignite.cache.*; +import org.apache.ignite.internal.processors.cache.*; +import org.jetbrains.annotations.*; + +/** + * Provides possibility to integrate cache transactions with JTA. + */ +public abstract class CacheJtaManagerAdapter<K, V> extends GridCacheManagerAdapter<K, V> { + /** + * Creates transaction manager finder. + * + * @param ccfg Cache configuration. + * @throws IgniteCheckedException If failed. + */ + public abstract void createTmLookup(CacheConfiguration ccfg) throws IgniteCheckedException; + + /** + * Checks if cache is working in JTA transaction and enlist cache as XAResource if necessary. + * + * @throws IgniteCheckedException In case of error. + */ + public abstract void checkJta() throws IgniteCheckedException; + + /** + * Gets transaction manager finder. Returns Object to avoid dependency on JTA library. + * + * @return Transaction manager finder. + */ + @Nullable public abstract Object tmLookup(); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4187cb06/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheNoopJtaManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheNoopJtaManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheNoopJtaManager.java new file mode 100644 index 0000000..54cbe4c --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheNoopJtaManager.java @@ -0,0 +1,42 @@ +/* + * 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.cache.jta; + +import org.apache.ignite.*; +import org.apache.ignite.cache.*; +import org.jetbrains.annotations.*; + +/** + * No-op implementation of {@link CacheJtaManagerAdapter}. + */ +public class CacheNoopJtaManager<K, V> extends CacheJtaManagerAdapter<K, V> { + /** {@inheritDoc} */ + @Override public void checkJta() throws IgniteCheckedException { + // No-op. + } + + /** {@inheritDoc} */ + @Override public void createTmLookup(CacheConfiguration ccfg) throws IgniteCheckedException { + // No-op. + } + + /** {@inheritDoc} */ + @Nullable @Override public Object tmLookup() { + return null; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4187cb06/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/jta/GridCacheJtaManagerAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/jta/GridCacheJtaManagerAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/jta/GridCacheJtaManagerAdapter.java deleted file mode 100644 index 2c8291f..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/jta/GridCacheJtaManagerAdapter.java +++ /dev/null @@ -1,50 +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.internal.processors.cache.jta; - -import org.apache.ignite.*; -import org.apache.ignite.cache.*; -import org.apache.ignite.internal.processors.cache.*; -import org.jetbrains.annotations.*; - -/** - * Provides possibility to integrate cache transactions with JTA. - */ -public abstract class GridCacheJtaManagerAdapter<K, V> extends GridCacheManagerAdapter<K, V> { - /** - * Creates transaction manager finder. - * - * @param ccfg Cache configuration. - * @throws IgniteCheckedException If failed. - */ - public abstract void createTmLookup(CacheConfiguration ccfg) throws IgniteCheckedException; - - /** - * Checks if cache is working in JTA transaction and enlist cache as XAResource if necessary. - * - * @throws IgniteCheckedException In case of error. - */ - public abstract void checkJta() throws IgniteCheckedException; - - /** - * Gets transaction manager finder. Returns Object to avoid dependency on JTA library. - * - * @return Transaction manager finder. - */ - @Nullable public abstract Object tmLookup(); -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4187cb06/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/jta/GridCacheNoopJtaManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/jta/GridCacheNoopJtaManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/jta/GridCacheNoopJtaManager.java deleted file mode 100644 index 25aa3ca..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/jta/GridCacheNoopJtaManager.java +++ /dev/null @@ -1,42 +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.internal.processors.cache.jta; - -import org.apache.ignite.*; -import org.apache.ignite.cache.*; -import org.jetbrains.annotations.*; - -/** - * No-op implementation of {@link GridCacheJtaManagerAdapter}. - */ -public class GridCacheNoopJtaManager<K, V> extends GridCacheJtaManagerAdapter<K, V> { - /** {@inheritDoc} */ - @Override public void checkJta() throws IgniteCheckedException { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void createTmLookup(CacheConfiguration ccfg) throws IgniteCheckedException { - // No-op. - } - - /** {@inheritDoc} */ - @Nullable @Override public Object tmLookup() { - return null; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4187cb06/modules/core/src/main/java/org/apache/ignite/internal/processors/email/GridEmailProcessorAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/email/GridEmailProcessorAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/email/GridEmailProcessorAdapter.java deleted file mode 100644 index 57e03ac..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/email/GridEmailProcessorAdapter.java +++ /dev/null @@ -1,85 +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.internal.processors.email; - -import org.apache.ignite.*; -import org.apache.ignite.internal.*; -import org.apache.ignite.internal.processors.*; -import org.apache.ignite.lang.*; - -import java.util.*; - -/** - * Email processor. - */ -public abstract class GridEmailProcessorAdapter extends GridProcessorAdapter { - /** - * @param ctx Kernal context. - */ - protected GridEmailProcessorAdapter(GridKernalContext ctx) { - super(ctx); - } - - /** - * Sends given email to all admin emails, if any, in the current thread blocking until it's either - * successfully sent or failed. If SMTP is disabled or admin emails are not provided - this method is no-op. - * - * @param subj Email subject. - * @param body Email body. - * @param html HTML format flag. - * @throws IgniteCheckedException Thrown in case of any failure on sending. - */ - public abstract void sendNow(String subj, String body, boolean html) throws IgniteCheckedException; - - /** - * Sends given email in the current thread blocking until it's either successfully sent or failed. - * If SMTP is disabled - this method is no-op. - * - * @param subj Email subject. - * @param body Email body. - * @param html HTML format flag. - * @param addrs Addresses. - * @throws IgniteCheckedException Thrown in case of any failure on sending. - */ - public abstract void sendNow(String subj, String body, boolean html, Collection<String> addrs) throws IgniteCheckedException; - - /** - * Schedules sending of given email to all admin emails, if any. If SMTP is disabled or admin emails - * are not provided - this method is no-op. Emails will be send asynchronously from a different thread. - * If email sending fails - the error log will be created for each email. - * - * @param subj Email subject. - * @param body Email body. - * @param html HTML format flag. - * @return Future for scheduled email. - */ - public abstract IgniteFuture<Boolean> schedule(String subj, String body, boolean html); - - /** - * Schedules sending of given email. If SMTP is disabled - this method is no-op. Emails will be send - * asynchronously from a different thread. If email sending fails - the error log will be created - * for each email. - * - * @param subj Email subject. - * @param body Email body. - * @param html HTML format flag. - * @param addrs Addresses. - * @return Future for scheduled email. - */ - public abstract IgniteFuture<Boolean> schedule(String subj, String body, boolean html, Collection<String> addrs); -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4187cb06/modules/core/src/main/java/org/apache/ignite/internal/processors/email/GridNoopEmailProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/email/GridNoopEmailProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/email/GridNoopEmailProcessor.java deleted file mode 100644 index 93a2bd6..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/email/GridNoopEmailProcessor.java +++ /dev/null @@ -1,56 +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.internal.processors.email; - -import org.apache.ignite.internal.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.internal.util.future.*; - -import java.util.*; - -/** - * No-op implementation of {@code GridEmailProcessorAdapter}. - */ -public class GridNoopEmailProcessor extends GridEmailProcessorAdapter { - /** - * @param ctx Kernal context. - */ - public GridNoopEmailProcessor(GridKernalContext ctx) { - super(ctx); - } - - /** {@inheritDoc} */ - @Override public void sendNow(String subj, String body, boolean html) { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void sendNow(String subj, String body, boolean html, Collection<String> addrs) { - // No-op. - } - - /** {@inheritDoc} */ - @Override public IgniteFuture<Boolean> schedule(String subj, String body, boolean html) { - return new GridFinishedFuture<>(ctx, true); - } - - /** {@inheritDoc} */ - @Override public IgniteFuture<Boolean> schedule(String subj, String body, boolean html, Collection<String> addrs) { - return new GridFinishedFuture<>(ctx, true); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4187cb06/modules/core/src/main/java/org/apache/ignite/internal/processors/email/IgniteEmailProcessorAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/email/IgniteEmailProcessorAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/email/IgniteEmailProcessorAdapter.java new file mode 100644 index 0000000..3a383d1 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/email/IgniteEmailProcessorAdapter.java @@ -0,0 +1,85 @@ +/* + * 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.email; + +import org.apache.ignite.*; +import org.apache.ignite.internal.*; +import org.apache.ignite.internal.processors.*; +import org.apache.ignite.lang.*; + +import java.util.*; + +/** + * Email processor. + */ +public abstract class IgniteEmailProcessorAdapter extends GridProcessorAdapter { + /** + * @param ctx Kernal context. + */ + protected IgniteEmailProcessorAdapter(GridKernalContext ctx) { + super(ctx); + } + + /** + * Sends given email to all admin emails, if any, in the current thread blocking until it's either + * successfully sent or failed. If SMTP is disabled or admin emails are not provided - this method is no-op. + * + * @param subj Email subject. + * @param body Email body. + * @param html HTML format flag. + * @throws IgniteCheckedException Thrown in case of any failure on sending. + */ + public abstract void sendNow(String subj, String body, boolean html) throws IgniteCheckedException; + + /** + * Sends given email in the current thread blocking until it's either successfully sent or failed. + * If SMTP is disabled - this method is no-op. + * + * @param subj Email subject. + * @param body Email body. + * @param html HTML format flag. + * @param addrs Addresses. + * @throws IgniteCheckedException Thrown in case of any failure on sending. + */ + public abstract void sendNow(String subj, String body, boolean html, Collection<String> addrs) throws IgniteCheckedException; + + /** + * Schedules sending of given email to all admin emails, if any. If SMTP is disabled or admin emails + * are not provided - this method is no-op. Emails will be send asynchronously from a different thread. + * If email sending fails - the error log will be created for each email. + * + * @param subj Email subject. + * @param body Email body. + * @param html HTML format flag. + * @return Future for scheduled email. + */ + public abstract IgniteFuture<Boolean> schedule(String subj, String body, boolean html); + + /** + * Schedules sending of given email. If SMTP is disabled - this method is no-op. Emails will be send + * asynchronously from a different thread. If email sending fails - the error log will be created + * for each email. + * + * @param subj Email subject. + * @param body Email body. + * @param html HTML format flag. + * @param addrs Addresses. + * @return Future for scheduled email. + */ + public abstract IgniteFuture<Boolean> schedule(String subj, String body, boolean html, Collection<String> addrs); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4187cb06/modules/core/src/main/java/org/apache/ignite/internal/processors/email/IgniteNoopEmailProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/email/IgniteNoopEmailProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/email/IgniteNoopEmailProcessor.java new file mode 100644 index 0000000..5d97490 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/email/IgniteNoopEmailProcessor.java @@ -0,0 +1,56 @@ +/* + * 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.email; + +import org.apache.ignite.internal.*; +import org.apache.ignite.lang.*; +import org.apache.ignite.internal.util.future.*; + +import java.util.*; + +/** + * No-op implementation of {@code GridEmailProcessorAdapter}. + */ +public class IgniteNoopEmailProcessor extends IgniteEmailProcessorAdapter { + /** + * @param ctx Kernal context. + */ + public IgniteNoopEmailProcessor(GridKernalContext ctx) { + super(ctx); + } + + /** {@inheritDoc} */ + @Override public void sendNow(String subj, String body, boolean html) { + // No-op. + } + + /** {@inheritDoc} */ + @Override public void sendNow(String subj, String body, boolean html, Collection<String> addrs) { + // No-op. + } + + /** {@inheritDoc} */ + @Override public IgniteFuture<Boolean> schedule(String subj, String body, boolean html) { + return new GridFinishedFuture<>(ctx, true); + } + + /** {@inheritDoc} */ + @Override public IgniteFuture<Boolean> schedule(String subj, String body, boolean html, Collection<String> addrs) { + return new GridFinishedFuture<>(ctx, true); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4187cb06/modules/core/src/main/java/org/apache/ignite/internal/processors/schedule/GridNoopScheduleProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/schedule/GridNoopScheduleProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/schedule/GridNoopScheduleProcessor.java deleted file mode 100644 index 04dce0c..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/schedule/GridNoopScheduleProcessor.java +++ /dev/null @@ -1,54 +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.internal.processors.schedule; - -import org.apache.ignite.*; -import org.apache.ignite.internal.*; -import org.apache.ignite.scheduler.*; - -import java.util.concurrent.*; - -/** - * No-op implementation of {@link GridScheduleProcessorAdapter}, throws exception on usage attempt. - */ -public class GridNoopScheduleProcessor extends GridScheduleProcessorAdapter { - /** - * @param ctx Kernal context. - */ - public GridNoopScheduleProcessor(GridKernalContext ctx) { - super(ctx); - } - - /** {@inheritDoc} */ - @Override public SchedulerFuture<?> schedule(Runnable c, String pattern) { - throw processorException(); - } - - /** {@inheritDoc} */ - @Override public <R> SchedulerFuture<R> schedule(Callable<R> c, String pattern) { - throw processorException(); - } - - /** - * @return No-op processor usage exception; - */ - private IgniteException processorException() { - return new IgniteException("Current GridGain configuration does not support schedule functionality " + - "(consider adding gridgain-schedule module to classpath)."); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4187cb06/modules/core/src/main/java/org/apache/ignite/internal/processors/schedule/GridScheduleProcessorAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/schedule/GridScheduleProcessorAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/schedule/GridScheduleProcessorAdapter.java deleted file mode 100644 index 682df54..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/schedule/GridScheduleProcessorAdapter.java +++ /dev/null @@ -1,53 +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.internal.processors.schedule; - -import org.apache.ignite.internal.*; -import org.apache.ignite.internal.processors.*; -import org.apache.ignite.scheduler.*; - -import java.util.concurrent.*; - -/** - * Schedules cron-based execution of grid tasks and closures. Abstract class was introduced to - * avoid mandatory runtime dependency on cron library. - */ -public abstract class GridScheduleProcessorAdapter extends GridProcessorAdapter { - /** - * @param ctx Kernal context. - */ - protected GridScheduleProcessorAdapter(GridKernalContext ctx) { - super(ctx); - } - - /** - * @param c Closure to schedule to run as a background cron-based job. - * @param pattern Scheduling pattern in UNIX cron format with prefix "{n1, n2} " where n1 is delay of scheduling - * and n2 is the number of task calls. - * @return Descriptor of the scheduled execution. - */ - public abstract SchedulerFuture<?> schedule(final Runnable c, String pattern); - - /** - * @param c Closure to schedule to run as a background cron-based job. - * @param pattern Scheduling pattern in UNIX cron format with prefix "{n1, n2} " where n1 is delay of scheduling - * and n2 is the number of task calls. - * @return Descriptor of the scheduled execution. - */ - public abstract <R> SchedulerFuture<R> schedule(Callable<R> c, String pattern); -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4187cb06/modules/core/src/main/java/org/apache/ignite/internal/processors/schedule/IgniteNoopScheduleProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/schedule/IgniteNoopScheduleProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/schedule/IgniteNoopScheduleProcessor.java new file mode 100644 index 0000000..ab6e322 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/schedule/IgniteNoopScheduleProcessor.java @@ -0,0 +1,54 @@ +/* + * 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.schedule; + +import org.apache.ignite.*; +import org.apache.ignite.internal.*; +import org.apache.ignite.scheduler.*; + +import java.util.concurrent.*; + +/** + * No-op implementation of {@link IgniteScheduleProcessorAdapter}, throws exception on usage attempt. + */ +public class IgniteNoopScheduleProcessor extends IgniteScheduleProcessorAdapter { + /** + * @param ctx Kernal context. + */ + public IgniteNoopScheduleProcessor(GridKernalContext ctx) { + super(ctx); + } + + /** {@inheritDoc} */ + @Override public SchedulerFuture<?> schedule(Runnable c, String pattern) { + throw processorException(); + } + + /** {@inheritDoc} */ + @Override public <R> SchedulerFuture<R> schedule(Callable<R> c, String pattern) { + throw processorException(); + } + + /** + * @return No-op processor usage exception; + */ + private IgniteException processorException() { + return new IgniteException("Current GridGain configuration does not support schedule functionality " + + "(consider adding gridgain-schedule module to classpath)."); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4187cb06/modules/core/src/main/java/org/apache/ignite/internal/processors/schedule/IgniteScheduleProcessorAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/schedule/IgniteScheduleProcessorAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/schedule/IgniteScheduleProcessorAdapter.java new file mode 100644 index 0000000..e512d1d --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/schedule/IgniteScheduleProcessorAdapter.java @@ -0,0 +1,53 @@ +/* + * 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.schedule; + +import org.apache.ignite.internal.*; +import org.apache.ignite.internal.processors.*; +import org.apache.ignite.scheduler.*; + +import java.util.concurrent.*; + +/** + * Schedules cron-based execution of grid tasks and closures. Abstract class was introduced to + * avoid mandatory runtime dependency on cron library. + */ +public abstract class IgniteScheduleProcessorAdapter extends GridProcessorAdapter { + /** + * @param ctx Kernal context. + */ + protected IgniteScheduleProcessorAdapter(GridKernalContext ctx) { + super(ctx); + } + + /** + * @param c Closure to schedule to run as a background cron-based job. + * @param pattern Scheduling pattern in UNIX cron format with prefix "{n1, n2} " where n1 is delay of scheduling + * and n2 is the number of task calls. + * @return Descriptor of the scheduled execution. + */ + public abstract SchedulerFuture<?> schedule(final Runnable c, String pattern); + + /** + * @param c Closure to schedule to run as a background cron-based job. + * @param pattern Scheduling pattern in UNIX cron format with prefix "{n1, n2} " where n1 is delay of scheduling + * and n2 is the number of task calls. + * @return Descriptor of the scheduled execution. + */ + public abstract <R> SchedulerFuture<R> schedule(Callable<R> c, String pattern); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4187cb06/modules/core/src/main/java/org/apache/ignite/internal/util/nodestart/GridSshProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nodestart/GridSshProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nodestart/GridSshProcessor.java deleted file mode 100644 index 3474104..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/nodestart/GridSshProcessor.java +++ /dev/null @@ -1,34 +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.internal.util.nodestart; - -import java.util.concurrent.*; - -/** - * SSH processor, interface was introduced to avoid mandatory runtime dependency on SSH library. - */ -public interface GridSshProcessor { - /** - * Creates {@link Callable} starting node using SSH. - * - * @param spec Specification. - * @param timeout Connection timeout. - * @return {@link Callable} starting node using SSH. - */ - public GridNodeCallable nodeStartCallable(GridRemoteStartSpecification spec, int timeout); -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4187cb06/modules/core/src/main/java/org/apache/ignite/internal/util/nodestart/IgniteSshProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nodestart/IgniteSshProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nodestart/IgniteSshProcessor.java new file mode 100644 index 0000000..3b68ee8 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nodestart/IgniteSshProcessor.java @@ -0,0 +1,34 @@ +/* + * 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.util.nodestart; + +import java.util.concurrent.*; + +/** + * SSH processor, interface was introduced to avoid mandatory runtime dependency on SSH library. + */ +public interface IgniteSshProcessor { + /** + * Creates {@link Callable} starting node using SSH. + * + * @param spec Specification. + * @param timeout Connection timeout. + * @return {@link Callable} starting node using SSH. + */ + public GridNodeCallable nodeStartCallable(GridRemoteStartSpecification spec, int timeout); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4187cb06/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java b/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java index e76888e..e580986 100644 --- a/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java +++ b/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java @@ -67,6 +67,6 @@ public class GridCacheTestContext<K, V> extends GridCacheContext<K, V> { new GridCacheDataStructuresManager<K, V>(), new GridCacheTtlManager<K, V>(), new GridOsCacheDrManager<K, V>(), - new GridCacheNoopJtaManager<K, V>()); + new CacheNoopJtaManager<K, V>()); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4187cb06/modules/email/src/main/java/org/apache/ignite/internal/processors/email/GridEmailProcessor.java ---------------------------------------------------------------------- diff --git a/modules/email/src/main/java/org/apache/ignite/internal/processors/email/GridEmailProcessor.java b/modules/email/src/main/java/org/apache/ignite/internal/processors/email/GridEmailProcessor.java deleted file mode 100644 index 9cb93cd..0000000 --- a/modules/email/src/main/java/org/apache/ignite/internal/processors/email/GridEmailProcessor.java +++ /dev/null @@ -1,297 +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.internal.processors.email; - -import org.apache.ignite.*; -import org.apache.ignite.configuration.*; -import org.apache.ignite.internal.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.thread.*; -import org.apache.ignite.internal.util.future.*; -import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.internal.util.worker.*; - -import javax.mail.*; -import javax.mail.internet.*; -import java.util.*; - -/** - * Email (SMTP) processor. Responsible for sending emails. - */ -public class GridEmailProcessor extends GridEmailProcessorAdapter { - /** Maximum emails queue size. */ - public static final int QUEUE_SIZE = 1024; - - /** */ - @SuppressWarnings({"FieldAccessedSynchronizedAndUnsynchronized"}) - private Deque<GridEmailHolder> q; - - /** */ - private IgniteThread snd; - - /** */ - private GridWorker worker; - - /** */ - private final boolean isSmtpEnabled; - - /** - * @param ctx Kernal context. - */ - public GridEmailProcessor(GridKernalContext ctx) { - super(ctx); - - isSmtpEnabled = ctx.config().getSmtpHost() != null; - - if (isSmtpEnabled) { - worker = new GridWorker(ctx.config().getGridName(), "email-sender-worker", log) { - @SuppressWarnings({"SynchronizeOnNonFinalField"}) - @Override protected void body() throws InterruptedException { - while (!Thread.currentThread().isInterrupted()) - synchronized (q) { - while (q.isEmpty()) - q.wait(); - - GridEmailHolder email = q.removeFirst(); - - assert email != null; - - try { - sendNow(email.subject(), email.body(), email.html(), email.addresses()); - - email.future().onDone(true); - } - catch (IgniteCheckedException e) { - U.error(log, "Failed to send email with subject: " + email.subject(), e); - - email.future().onDone(e); - } - } - } - }; - } - } - - /** {@inheritDoc} */ - @Override public void start() throws IgniteCheckedException { - if (isSmtpEnabled) { - assert q == null; - assert snd == null; - - q = new LinkedList<>(); - - snd = new IgniteThread(ctx.config().getGridName(), "email-sender-thread", worker); - - snd.start(); - } - - if (log.isDebugEnabled()) - log.debug("Started email processor" + (isSmtpEnabled ? "." : " (inactive).")); - } - - /** {@inheritDoc} */ - @Override public void stop(boolean cancel) throws IgniteCheckedException { - if (isSmtpEnabled) { - U.interrupt(snd); - U.join(snd, log); - - snd = null; - - if (q != null) { - if (!q.isEmpty()) - U.warn(log, "Emails queue is not empty on email processor stop."); - - q.clear(); - - q = null; - } - } - - if (log.isDebugEnabled()) - log.debug("Stopped email processor."); - } - - /** {@inheritDoc} */ - @Override public void sendNow(String subj, String body, boolean html) throws IgniteCheckedException { - String[] addrs = ctx.config().getAdminEmails(); - - if (addrs != null && addrs.length > 0) - sendNow(subj, body, html, Arrays.asList(addrs)); - } - - /** {@inheritDoc} */ - @Override public void sendNow(String subj, String body, boolean html, Collection<String> addrs) - throws IgniteCheckedException { - assert subj != null; - assert body != null; - assert addrs != null; - assert !addrs.isEmpty(); - - if (isSmtpEnabled) { - IgniteConfiguration cfg = ctx.config(); - - sendEmail( - // Static SMTP configuration data. - cfg.getSmtpHost(), - cfg.getSmtpPort(), - cfg.isSmtpSsl(), - cfg.isSmtpStartTls(), - cfg.getSmtpUsername(), - cfg.getSmtpPassword(), - cfg.getSmtpFromEmail(), - - // Per-email data. - subj, - body, - html, - addrs - ); - } - } - - /** {@inheritDoc} */ - @Override public IgniteFuture<Boolean> schedule(String subj, String body, boolean html) { - String[] addrs = ctx.config().getAdminEmails(); - - return addrs == null || addrs.length == 0 ? new GridFinishedFuture<>(ctx, false) : - schedule(subj, body, html, Arrays.asList(addrs)); - } - - /** {@inheritDoc} */ - @SuppressWarnings({"SynchronizeOnNonFinalField"}) - @Override public IgniteFuture<Boolean> schedule(String subj, String body, boolean html, Collection<String> addrs) { - assert subj != null; - assert body != null; - assert addrs != null; - assert !addrs.isEmpty(); - - if (isSmtpEnabled) - synchronized (q) { - if (q.size() == QUEUE_SIZE) { - U.warn(log, "Email '" + subj + "' failed to schedule b/c queue is full."); - - return new GridFinishedFuture<>(ctx, false); - } - else { - GridFutureAdapter<Boolean> fut = new GridFutureAdapter<Boolean>(ctx) { - @SuppressWarnings({"SynchronizeOnNonFinalField"}) - @Override public boolean cancel() { - synchronized (q) { - for (GridEmailHolder email : q) - if (email.future() == this) { - q.remove(email); // We accept full scan on removal here. - - return true; - } - } - - return false; - } - }; - - q.addLast(new GridEmailHolder(fut, subj, body, html, addrs)); - - q.notifyAll(); - - return fut; - } - } - else - return new GridFinishedFuture<>(ctx, false); - } - /** - * - * @param smtpHost SMTP host. - * @param smtpPort SMTP port. - * @param ssl SMTP SSL. - * @param startTls Start TLS flag. - * @param username Email authentication user name. - * @param pwd Email authentication password. - * @param from From email. - * @param subj Email subject. - * @param body Email body. - * @param html HTML format flag. - * @param addrs Addresses to send email to. - * @throws IgniteCheckedException Thrown in case when sending email failed. - */ - public static void sendEmail(String smtpHost, int smtpPort, boolean ssl, boolean startTls, final String username, - final String pwd, String from, String subj, String body, boolean html, Collection<String> addrs) - throws IgniteCheckedException { - assert smtpHost != null; - assert smtpPort > 0; - assert from != null; - assert subj != null; - assert body != null; - assert addrs != null; - assert !addrs.isEmpty(); - - Properties props = new Properties(); - - props.setProperty("mail.transport.protocol", "smtp"); - props.setProperty("mail.smtp.host", smtpHost); - props.setProperty("mail.smtp.port", Integer.toString(smtpPort)); - - if (ssl) - props.setProperty("mail.smtp.ssl", "true"); - - if (startTls) - props.setProperty("mail.smtp.starttls.enable", "true"); - - Authenticator auth = null; - - // Add property for authentication by username. - if (username != null && !username.isEmpty()) { - props.setProperty("mail.smtp.auth", "true"); - - auth = new Authenticator() { - @Override public PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(username, pwd); - } - }; - } - - Session ses = Session.getInstance(props, auth); - - MimeMessage email = new MimeMessage(ses); - - try { - email.setFrom(new InternetAddress(from)); - email.setSubject(subj); - email.setSentDate(new Date()); - - if (html) - email.setText(body, "UTF-8", "html"); - else - email.setText(body); - - Address[] rcpts = new Address[addrs.size()]; - - int i = 0; - - for (String addr : addrs) - rcpts[i++] = new InternetAddress(addr); - - email.setRecipients(MimeMessage.RecipientType.TO, rcpts); - - Transport.send(email); - } - catch (MessagingException e) { - throw new IgniteCheckedException("Failed to send email.", e); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4187cb06/modules/email/src/main/java/org/apache/ignite/internal/processors/email/IgniteEmailProcessor.java ---------------------------------------------------------------------- diff --git a/modules/email/src/main/java/org/apache/ignite/internal/processors/email/IgniteEmailProcessor.java b/modules/email/src/main/java/org/apache/ignite/internal/processors/email/IgniteEmailProcessor.java new file mode 100644 index 0000000..0fa56cc --- /dev/null +++ b/modules/email/src/main/java/org/apache/ignite/internal/processors/email/IgniteEmailProcessor.java @@ -0,0 +1,297 @@ +/* + * 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.email; + +import org.apache.ignite.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.internal.*; +import org.apache.ignite.lang.*; +import org.apache.ignite.thread.*; +import org.apache.ignite.internal.util.future.*; +import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.internal.util.worker.*; + +import javax.mail.*; +import javax.mail.internet.*; +import java.util.*; + +/** + * Email (SMTP) processor. Responsible for sending emails. + */ +public class IgniteEmailProcessor extends IgniteEmailProcessorAdapter { + /** Maximum emails queue size. */ + public static final int QUEUE_SIZE = 1024; + + /** */ + @SuppressWarnings({"FieldAccessedSynchronizedAndUnsynchronized"}) + private Deque<GridEmailHolder> q; + + /** */ + private IgniteThread snd; + + /** */ + private GridWorker worker; + + /** */ + private final boolean isSmtpEnabled; + + /** + * @param ctx Kernal context. + */ + public IgniteEmailProcessor(GridKernalContext ctx) { + super(ctx); + + isSmtpEnabled = ctx.config().getSmtpHost() != null; + + if (isSmtpEnabled) { + worker = new GridWorker(ctx.config().getGridName(), "email-sender-worker", log) { + @SuppressWarnings({"SynchronizeOnNonFinalField"}) + @Override protected void body() throws InterruptedException { + while (!Thread.currentThread().isInterrupted()) + synchronized (q) { + while (q.isEmpty()) + q.wait(); + + GridEmailHolder email = q.removeFirst(); + + assert email != null; + + try { + sendNow(email.subject(), email.body(), email.html(), email.addresses()); + + email.future().onDone(true); + } + catch (IgniteCheckedException e) { + U.error(log, "Failed to send email with subject: " + email.subject(), e); + + email.future().onDone(e); + } + } + } + }; + } + } + + /** {@inheritDoc} */ + @Override public void start() throws IgniteCheckedException { + if (isSmtpEnabled) { + assert q == null; + assert snd == null; + + q = new LinkedList<>(); + + snd = new IgniteThread(ctx.config().getGridName(), "email-sender-thread", worker); + + snd.start(); + } + + if (log.isDebugEnabled()) + log.debug("Started email processor" + (isSmtpEnabled ? "." : " (inactive).")); + } + + /** {@inheritDoc} */ + @Override public void stop(boolean cancel) throws IgniteCheckedException { + if (isSmtpEnabled) { + U.interrupt(snd); + U.join(snd, log); + + snd = null; + + if (q != null) { + if (!q.isEmpty()) + U.warn(log, "Emails queue is not empty on email processor stop."); + + q.clear(); + + q = null; + } + } + + if (log.isDebugEnabled()) + log.debug("Stopped email processor."); + } + + /** {@inheritDoc} */ + @Override public void sendNow(String subj, String body, boolean html) throws IgniteCheckedException { + String[] addrs = ctx.config().getAdminEmails(); + + if (addrs != null && addrs.length > 0) + sendNow(subj, body, html, Arrays.asList(addrs)); + } + + /** {@inheritDoc} */ + @Override public void sendNow(String subj, String body, boolean html, Collection<String> addrs) + throws IgniteCheckedException { + assert subj != null; + assert body != null; + assert addrs != null; + assert !addrs.isEmpty(); + + if (isSmtpEnabled) { + IgniteConfiguration cfg = ctx.config(); + + sendEmail( + // Static SMTP configuration data. + cfg.getSmtpHost(), + cfg.getSmtpPort(), + cfg.isSmtpSsl(), + cfg.isSmtpStartTls(), + cfg.getSmtpUsername(), + cfg.getSmtpPassword(), + cfg.getSmtpFromEmail(), + + // Per-email data. + subj, + body, + html, + addrs + ); + } + } + + /** {@inheritDoc} */ + @Override public IgniteFuture<Boolean> schedule(String subj, String body, boolean html) { + String[] addrs = ctx.config().getAdminEmails(); + + return addrs == null || addrs.length == 0 ? new GridFinishedFuture<>(ctx, false) : + schedule(subj, body, html, Arrays.asList(addrs)); + } + + /** {@inheritDoc} */ + @SuppressWarnings({"SynchronizeOnNonFinalField"}) + @Override public IgniteFuture<Boolean> schedule(String subj, String body, boolean html, Collection<String> addrs) { + assert subj != null; + assert body != null; + assert addrs != null; + assert !addrs.isEmpty(); + + if (isSmtpEnabled) + synchronized (q) { + if (q.size() == QUEUE_SIZE) { + U.warn(log, "Email '" + subj + "' failed to schedule b/c queue is full."); + + return new GridFinishedFuture<>(ctx, false); + } + else { + GridFutureAdapter<Boolean> fut = new GridFutureAdapter<Boolean>(ctx) { + @SuppressWarnings({"SynchronizeOnNonFinalField"}) + @Override public boolean cancel() { + synchronized (q) { + for (GridEmailHolder email : q) + if (email.future() == this) { + q.remove(email); // We accept full scan on removal here. + + return true; + } + } + + return false; + } + }; + + q.addLast(new GridEmailHolder(fut, subj, body, html, addrs)); + + q.notifyAll(); + + return fut; + } + } + else + return new GridFinishedFuture<>(ctx, false); + } + /** + * + * @param smtpHost SMTP host. + * @param smtpPort SMTP port. + * @param ssl SMTP SSL. + * @param startTls Start TLS flag. + * @param username Email authentication user name. + * @param pwd Email authentication password. + * @param from From email. + * @param subj Email subject. + * @param body Email body. + * @param html HTML format flag. + * @param addrs Addresses to send email to. + * @throws IgniteCheckedException Thrown in case when sending email failed. + */ + public static void sendEmail(String smtpHost, int smtpPort, boolean ssl, boolean startTls, final String username, + final String pwd, String from, String subj, String body, boolean html, Collection<String> addrs) + throws IgniteCheckedException { + assert smtpHost != null; + assert smtpPort > 0; + assert from != null; + assert subj != null; + assert body != null; + assert addrs != null; + assert !addrs.isEmpty(); + + Properties props = new Properties(); + + props.setProperty("mail.transport.protocol", "smtp"); + props.setProperty("mail.smtp.host", smtpHost); + props.setProperty("mail.smtp.port", Integer.toString(smtpPort)); + + if (ssl) + props.setProperty("mail.smtp.ssl", "true"); + + if (startTls) + props.setProperty("mail.smtp.starttls.enable", "true"); + + Authenticator auth = null; + + // Add property for authentication by username. + if (username != null && !username.isEmpty()) { + props.setProperty("mail.smtp.auth", "true"); + + auth = new Authenticator() { + @Override public PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, pwd); + } + }; + } + + Session ses = Session.getInstance(props, auth); + + MimeMessage email = new MimeMessage(ses); + + try { + email.setFrom(new InternetAddress(from)); + email.setSubject(subj); + email.setSentDate(new Date()); + + if (html) + email.setText(body, "UTF-8", "html"); + else + email.setText(body); + + Address[] rcpts = new Address[addrs.size()]; + + int i = 0; + + for (String addr : addrs) + rcpts[i++] = new InternetAddress(addr); + + email.setRecipients(MimeMessage.RecipientType.TO, rcpts); + + Transport.send(email); + } + catch (MessagingException e) { + throw new IgniteCheckedException("Failed to send email.", e); + } + } +}