http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/events/JobEvent.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/events/JobEvent.java index 98ec85a,0000000..a810c29 mode 100644,000000..100644 --- a/modules/core/src/main/java/org/apache/ignite/events/JobEvent.java +++ b/modules/core/src/main/java/org/apache/ignite/events/JobEvent.java @@@ -1,236 -1,0 +1,236 @@@ +/* + * 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.events; + +import org.apache.ignite.cluster.*; +import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.lang.*; + +import java.util.*; + +/** + * Grid job event. + * <p> + * Grid events are used for notification about what happens within the grid. Note that by - * design GridGain keeps all events generated on the local node locally and it provides ++ * design Ignite keeps all events generated on the local node locally and it provides + * APIs for performing a distributed queries across multiple nodes: + * <ul> + * <li> + * {@link org.apache.ignite.IgniteEvents#remoteQuery(org.apache.ignite.lang.IgnitePredicate, long, int...)} - + * asynchronously querying events occurred on the nodes specified, including remote nodes. + * </li> + * <li> + * {@link org.apache.ignite.IgniteEvents#localQuery(org.apache.ignite.lang.IgnitePredicate, int...)} - + * querying only local events stored on this local node. + * </li> + * <li> + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} - + * listening to local grid events (events from remote nodes not included). + * </li> + * </ul> + * User can also wait for events using method {@link org.apache.ignite.IgniteEvents#waitForLocal(org.apache.ignite.lang.IgnitePredicate, int...)}. + * <h1 class="header">Events and Performance</h1> - * Note that by default all events in GridGain are enabled and therefore generated and stored - * by whatever event storage SPI is configured. GridGain can and often does generate thousands events per seconds ++ * Note that by default all events in Ignite are enabled and therefore generated and stored ++ * by whatever event storage SPI is configured. Ignite can and often does generate thousands events per seconds + * under the load and therefore it creates a significant additional load on the system. If these events are + * not needed by the application this load is unnecessary and leads to significant performance degradation. + * <p> + * It is <b>highly recommended</b> to enable only those events that your application logic requires - * by using {@link org.apache.ignite.configuration.IgniteConfiguration#getIncludeEventTypes()} method in GridGain configuration. Note that certain - * events are required for GridGain's internal operations and such events will still be generated but not stored by ++ * by using {@link org.apache.ignite.configuration.IgniteConfiguration#getIncludeEventTypes()} method in Ignite configuration. Note that certain ++ * events are required for Ignite's internal operations and such events will still be generated but not stored by + * event storage SPI if they are disabled in GridGain configuration. + * @see EventType#EVT_JOB_CANCELLED + * @see EventType#EVT_JOB_FAILED + * @see EventType#EVT_JOB_FAILED_OVER + * @see EventType#EVT_JOB_FINISHED + * @see EventType#EVT_JOB_MAPPED + * @see EventType#EVT_JOB_QUEUED + * @see EventType#EVT_JOB_REJECTED + * @see EventType#EVT_JOB_RESULTED + * @see EventType#EVT_JOB_STARTED + * @see EventType#EVT_JOB_TIMEDOUT + * @see EventType#EVTS_JOB_EXECUTION + */ +public class JobEvent extends EventAdapter { + /** */ + private static final long serialVersionUID = 0L; + + /** */ + private String taskName; + + /** */ + private String taskClsName; + + /** */ + private IgniteUuid sesId; + + /** */ + private IgniteUuid jobId; + + /** */ + private ClusterNode taskNode; + + /** */ + private UUID taskSubjId; + + /** {@inheritDoc} */ + @Override public String shortDisplay() { + return name() + ": taskName=" + taskName; + } + + /** + * No-arg constructor. + */ + public JobEvent() { + // No-op. + } + + /** + * Creates job event with given parameters. + * + * @param node Node. + * @param msg Optional message. + * @param type Event type. + */ + public JobEvent(ClusterNode node, String msg, int type) { + super(node, msg, type); + } + + /** + * Gets name of the task that triggered the event. + * + * @return Name of the task that triggered the event. + */ + public String taskName() { + return taskName; + } + + /** + * Gets name of task class that triggered this event. + * + * @return Name of task class that triggered the event. + */ + public String taskClassName() { + return taskClsName; + } + + /** + * Gets task session ID of the task that triggered this event. + * + * @return Task session ID of the task that triggered the event. + */ + public IgniteUuid taskSessionId() { + return sesId; + } + + /** + * Gets job ID. + * + * @return Job ID. + */ + public IgniteUuid jobId() { + return jobId; + } + + /** + * Sets name of the task that triggered this event. + * + * @param taskName Task name to set. + */ + public void taskName(String taskName) { + assert taskName != null; + + this.taskName = taskName; + } + + /** + * Sets name of the task class that triggered this event. + * + * @param taskClsName Task class name to set. + */ + public void taskClassName(String taskClsName) { + this.taskClsName = taskClsName; + } + + /** + * Sets task session ID of the task that triggered this event. + * + * @param sesId Task session ID to set. + */ + public void taskSessionId(IgniteUuid sesId) { + assert sesId != null; + + this.sesId = sesId; + } + + /** + * Sets job ID. + * + * @param jobId Job ID to set. + */ + public void jobId(IgniteUuid jobId) { + assert jobId != null; + + this.jobId = jobId; + } + + /** + * Get node where parent task of the job has originated. + * + * @return Node where parent task of the job has originated. + */ + public ClusterNode taskNode() { + return taskNode; + } + + /** + * Sets node where parent task of the job has originated. + * + * @param taskNode Node where parent task of the job has originated. + */ + public void taskNode(ClusterNode taskNode) { + this.taskNode = taskNode; + } + + /** + * Gets task subject ID. + * + * @return Task subject ID. + */ + public UUID taskSubjectId() { + return taskSubjId; + } + + /** + * Sets task subject ID. + * + * @param taskSubjId Task subject ID. + */ + public void taskSubjectId(UUID taskSubjId) { + this.taskSubjId = taskSubjId; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(JobEvent.class, this, + "nodeId8", U.id8(node().id()), + "msg", message(), + "type", name(), + "tstamp", timestamp()); + } +}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/events/LicenseEvent.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/events/LicenseEvent.java index 46df275,0000000..a37b743 mode 100644,000000..100644 --- a/modules/core/src/main/java/org/apache/ignite/events/LicenseEvent.java +++ b/modules/core/src/main/java/org/apache/ignite/events/LicenseEvent.java @@@ -1,116 -1,0 +1,116 @@@ +/* + * 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.events; + +import org.apache.ignite.cluster.*; +import org.apache.ignite.internal.util.typedef.internal.*; + +import java.util.*; + +/** + * Grid license event. + * <p> + * Grid events are used for notification about what happens within the grid. Note that by - * design GridGain keeps all events generated on the local node locally and it provides ++ * design Ignite keeps all events generated on the local node locally and it provides + * APIs for performing a distributed queries across multiple nodes: + * <ul> + * <li> + * {@link org.apache.ignite.IgniteEvents#remoteQuery(org.apache.ignite.lang.IgnitePredicate, long, int...)} - + * asynchronously querying events occurred on the nodes specified, including remote nodes. + * </li> + * <li> + * {@link org.apache.ignite.IgniteEvents#localQuery(org.apache.ignite.lang.IgnitePredicate, int...)} - + * querying only local events stored on this local node. + * </li> + * <li> + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} - + * listening to local grid events (events from remote nodes not included). + * </li> + * </ul> + * User can also wait for events using method {@link org.apache.ignite.IgniteEvents#waitForLocal(org.apache.ignite.lang.IgnitePredicate, int...)}. + * <h1 class="header">Events and Performance</h1> - * Note that by default all events in GridGain are enabled and therefore generated and stored - * by whatever event storage SPI is configured. GridGain can and often does generate thousands events per seconds ++ * Note that by default all events in Ignite are enabled and therefore generated and stored ++ * by whatever event storage SPI is configured. Ignite can and often does generate thousands events per seconds + * under the load and therefore it creates a significant additional load on the system. If these events are + * not needed by the application this load is unnecessary and leads to significant performance degradation. + * <p> + * It is <b>highly recommended</b> to enable only those events that your application logic requires - * by using {@link org.apache.ignite.configuration.IgniteConfiguration#getIncludeEventTypes()} method in GridGain configuration. Note that certain - * events are required for GridGain's internal operations and such events will still be generated but not stored by - * event storage SPI if they are disabled in GridGain configuration. ++ * by using {@link org.apache.ignite.configuration.IgniteConfiguration#getIncludeEventTypes()} method in Ignite configuration. Note that certain ++ * events are required for Ignite's internal operations and such events will still be generated but not stored by ++ * event storage SPI if they are disabled in Ignite configuration. + * @see EventType#EVT_LIC_CLEARED + * @see EventType#EVT_LIC_GRACE_EXPIRED + * @see EventType#EVT_LIC_VIOLATION + */ +public class LicenseEvent extends EventAdapter { + /** */ + private static final long serialVersionUID = 0L; + + /** License ID. */ + private UUID licId; + + /** + * No-arg constructor. + */ + public LicenseEvent() { + // No-op. + } + + /** + * Creates license event with given parameters. + * + * @param node Node. + * @param msg Optional message. + * @param type Event type. + */ + public LicenseEvent(ClusterNode node, String msg, int type) { + super(node, msg, type); + } + + /** {@inheritDoc} */ + @Override public String shortDisplay() { + return name() + ": licId8=" + U.id8(licId) + ", msg=" + message(); + } + + /** + * Gets license ID. + * + * @return License ID. + */ + public UUID licenseId() { + return licId; + } + + /** + * Sets license ID. + * + * @param licId License ID to set. + */ + public void licenseId(UUID licId) { + this.licId = licId; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(LicenseEvent.class, this, + "nodeId8", U.id8(node().id()), + "msg", message(), + "type", name(), + "tstamp", timestamp()); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/events/SecureSessionEvent.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/events/SecureSessionEvent.java index 53f1ee5,0000000..44aa8f2 mode 100644,000000..100644 --- a/modules/core/src/main/java/org/apache/ignite/events/SecureSessionEvent.java +++ b/modules/core/src/main/java/org/apache/ignite/events/SecureSessionEvent.java @@@ -1,154 -1,0 +1,154 @@@ +/* + * 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.events; + +import org.apache.ignite.cluster.*; +import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.plugin.security.*; + +import java.util.*; + +/** + * Grid secure session validation event. + * <p> + * Grid events are used for notification about what happens within the grid. Note that by - * design GridGain keeps all events generated on the local node locally and it provides ++ * design Ignite keeps all events generated on the local node locally and it provides + * APIs for performing a distributed queries across multiple nodes: + * <ul> + * <li> + * {@link org.apache.ignite.IgniteEvents#remoteQuery(org.apache.ignite.lang.IgnitePredicate, long, int...)} - + * asynchronously querying events occurred on the nodes specified, including remote nodes. + * </li> + * <li> + * {@link org.apache.ignite.IgniteEvents#localQuery(org.apache.ignite.lang.IgnitePredicate, int...)} - + * querying only local events stored on this local node. + * </li> + * <li> + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} - + * listening to local grid events (events from remote nodes not included). + * </li> + * </ul> + * User can also wait for events using method {@link org.apache.ignite.IgniteEvents#waitForLocal(org.apache.ignite.lang.IgnitePredicate, int...)}. + * <h1 class="header">Events and Performance</h1> - * Note that by default all events in GridGain are enabled and therefore generated and stored - * by whatever event storage SPI is configured. GridGain can and often does generate thousands events per seconds ++ * Note that by default all events in Ignite are enabled and therefore generated and stored ++ * by whatever event storage SPI is configured. Ignite can and often does generate thousands events per seconds + * under the load and therefore it creates a significant additional load on the system. If these events are + * not needed by the application this load is unnecessary and leads to significant performance degradation. + * <p> + * It is <b>highly recommended</b> to enable only those events that your application logic requires - * by using {@link org.apache.ignite.configuration.IgniteConfiguration#getIncludeEventTypes()} method in GridGain configuration. Note that certain - * events are required for GridGain's internal operations and such events will still be generated but not stored by - * event storage SPI if they are disabled in GridGain configuration. ++ * by using {@link org.apache.ignite.configuration.IgniteConfiguration#getIncludeEventTypes()} method in Ignite configuration. Note that certain ++ * events are required for Ignite's internal operations and such events will still be generated but not stored by ++ * event storage SPI if they are disabled in Ignite configuration. + * @see EventType#EVT_SECURE_SESSION_VALIDATION_FAILED + * @see EventType#EVT_SECURE_SESSION_VALIDATION_SUCCEEDED + */ +public class SecureSessionEvent extends EventAdapter { + /** */ + private static final long serialVersionUID = 0L; + + /** Subject type. */ + private GridSecuritySubjectType subjType; + + /** Subject ID. */ + private UUID subjId; + + /** {@inheritDoc} */ + @Override public String shortDisplay() { + return name() + ": subjType=" + subjType; + } + + /** + * No-arg constructor. + */ + public SecureSessionEvent() { + // No-op. + } + + /** + * Creates secure session event with given parameters. + * + * @param node Node. + * @param msg Optional message. + * @param type Event type. + */ + public SecureSessionEvent(ClusterNode node, String msg, int type) { + super(node, msg, type); + } + + /** + * Creates secure session event with given parameters. + * + * @param node Node. + * @param msg Optional message. + * @param type Event type. + * @param subjType Subject type. + * @param subjId Subject ID. + */ + public SecureSessionEvent(ClusterNode node, String msg, int type, GridSecuritySubjectType subjType, + UUID subjId) { + super(node, msg, type); + + this.subjType = subjType; + this.subjId = subjId; + } + + /** + * Gets subject type that triggered the event. + * + * @return Subject type that triggered the event. + */ + public GridSecuritySubjectType subjectType() { + return subjType; + } + + /** + * Gets subject ID that triggered the event. + * + * @return Subject ID that triggered the event. + */ + public UUID subjectId() { + return subjId; + } + + /** + * Sets subject type that triggered the event. + * + * @param subjType Subject type to set. + */ + public void subjectType(GridSecuritySubjectType subjType) { + this.subjType = subjType; + } + + /** + * Sets subject ID that triggered the event. + * + * @param subjId Subject ID to set. + */ + public void subjectId(UUID subjId) { + this.subjId = subjId; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(SecureSessionEvent.class, this, + "nodeId8", U.id8(node().id()), + "msg", message(), + "type", name(), + "tstamp", timestamp()); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/events/SwapSpaceEvent.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/events/SwapSpaceEvent.java index adb9708,0000000..00e022e mode 100644,000000..100644 --- a/modules/core/src/main/java/org/apache/ignite/events/SwapSpaceEvent.java +++ b/modules/core/src/main/java/org/apache/ignite/events/SwapSpaceEvent.java @@@ -1,104 -1,0 +1,104 @@@ +/* + * 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.events; + +import org.apache.ignite.cluster.*; +import org.apache.ignite.internal.util.typedef.internal.*; +import org.jetbrains.annotations.*; + +/** + * Grid swap space event. + * <p> + * Grid events are used for notification about what happens within the grid. Note that by - * design GridGain keeps all events generated on the local node locally and it provides ++ * design Ignite keeps all events generated on the local node locally and it provides + * APIs for performing a distributed queries across multiple nodes: + * <ul> + * <li> + * {@link org.apache.ignite.IgniteEvents#remoteQuery(org.apache.ignite.lang.IgnitePredicate, long, int...)} - + * asynchronously querying events occurred on the nodes specified, including remote nodes. + * </li> + * <li> + * {@link org.apache.ignite.IgniteEvents#localQuery(org.apache.ignite.lang.IgnitePredicate, int...)} - + * querying only local events stored on this local node. + * </li> + * <li> + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} - + * listening to local grid events (events from remote nodes not included). + * </li> + * </ul> + * User can also wait for events using method {@link org.apache.ignite.IgniteEvents#waitForLocal(org.apache.ignite.lang.IgnitePredicate, int...)}. + * <h1 class="header">Events and Performance</h1> - * Note that by default all events in GridGain are enabled and therefore generated and stored - * by whatever event storage SPI is configured. GridGain can and often does generate thousands events per seconds ++ * Note that by default all events in Ignite are enabled and therefore generated and stored ++ * by whatever event storage SPI is configured. Ignite can and often does generate thousands events per seconds + * under the load and therefore it creates a significant additional load on the system. If these events are + * not needed by the application this load is unnecessary and leads to significant performance degradation. + * <p> + * It is <b>highly recommended</b> to enable only those events that your application logic requires - * by using {@link org.apache.ignite.configuration.IgniteConfiguration#getIncludeEventTypes()} method in GridGain configuration. Note that certain - * events are required for GridGain's internal operations and such events will still be generated but not stored by - * event storage SPI if they are disabled in GridGain configuration. ++ * by using {@link org.apache.ignite.configuration.IgniteConfiguration#getIncludeEventTypes()} method in Ignite configuration. Note that certain ++ * events are required for Ignite's internal operations and such events will still be generated but not stored by ++ * event storage SPI if they are disabled in Ignite configuration. + * @see EventType#EVT_SWAP_SPACE_DATA_READ + * @see EventType#EVT_SWAP_SPACE_DATA_STORED + * @see EventType#EVT_SWAP_SPACE_DATA_REMOVED + * @see EventType#EVT_SWAP_SPACE_CLEARED + * @see EventType#EVT_SWAP_SPACE_DATA_EVICTED + */ +public class SwapSpaceEvent extends EventAdapter { + /** */ + private static final long serialVersionUID = 0L; + + /** Swap space name. */ + private String space; + + /** + * Creates swap space event. + * + * @param node Node. + * @param msg Optional message. + * @param type Event type. + * @param space Swap space name ({@code null} for default space). + */ + public SwapSpaceEvent(ClusterNode node, String msg, int type, @Nullable String space) { + super(node, msg, type); + + this.space = space; + } + + /** + * Gets swap space name. + * + * @return Swap space name or {@code null} for default space. + */ + @Nullable public String space() { + return space; + } + + /** {@inheritDoc} */ + @Override public String shortDisplay() { + return name() + ": space=" + space; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(SwapSpaceEvent.class, this, + "nodeId8", U.id8(node().id()), + "msg", message(), + "type", name(), + "tstamp", timestamp()); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/events/TaskEvent.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/events/TaskEvent.java index 8ca310e,0000000..8307e3a mode 100644,000000..100644 --- a/modules/core/src/main/java/org/apache/ignite/events/TaskEvent.java +++ b/modules/core/src/main/java/org/apache/ignite/events/TaskEvent.java @@@ -1,168 -1,0 +1,168 @@@ +/* + * 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.events; + +import org.apache.ignite.cluster.*; +import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.lang.*; +import org.jetbrains.annotations.*; + +import java.util.*; + +/** + * Grid task event. + * <p> + * Grid events are used for notification about what happens within the grid. Note that by - * design GridGain keeps all events generated on the local node locally and it provides ++ * design Ignite keeps all events generated on the local node locally and it provides + * APIs for performing a distributed queries across multiple nodes: + * <ul> + * <li> + * {@link org.apache.ignite.IgniteEvents#remoteQuery(org.apache.ignite.lang.IgnitePredicate, long, int...)} - + * asynchronously querying events occurred on the nodes specified, including remote nodes. + * </li> + * <li> + * {@link org.apache.ignite.IgniteEvents#localQuery(org.apache.ignite.lang.IgnitePredicate, int...)} - + * querying only local events stored on this local node. + * </li> + * <li> + * {@link org.apache.ignite.IgniteEvents#localListen(org.apache.ignite.lang.IgnitePredicate, int...)} - + * listening to local grid events (events from remote nodes not included). + * </li> + * </ul> + * User can also wait for events using method {@link org.apache.ignite.IgniteEvents#waitForLocal(org.apache.ignite.lang.IgnitePredicate, int...)}. + * <h1 class="header">Events and Performance</h1> - * Note that by default all events in GridGain are enabled and therefore generated and stored - * by whatever event storage SPI is configured. GridGain can and often does generate thousands events per seconds ++ * Note that by default all events in Ignite are enabled and therefore generated and stored ++ * by whatever event storage SPI is configured. Ignite can and often does generate thousands events per seconds + * under the load and therefore it creates a significant additional load on the system. If these events are + * not needed by the application this load is unnecessary and leads to significant performance degradation. + * <p> + * It is <b>highly recommended</b> to enable only those events that your application logic requires - * by using {@link org.apache.ignite.configuration.IgniteConfiguration#getIncludeEventTypes()} method in GridGain configuration. Note that certain - * events are required for GridGain's internal operations and such events will still be generated but not stored by - * event storage SPI if they are disabled in GridGain configuration. ++ * by using {@link org.apache.ignite.configuration.IgniteConfiguration#getIncludeEventTypes()} method in Ignite configuration. Note that certain ++ * events are required for Ignite's internal operations and such events will still be generated but not stored by ++ * event storage SPI if they are disabled in Ignite configuration. + * @see EventType#EVT_TASK_FAILED + * @see EventType#EVT_TASK_FINISHED + * @see EventType#EVT_TASK_REDUCED + * @see EventType#EVT_TASK_STARTED + * @see EventType#EVT_TASK_SESSION_ATTR_SET + * @see EventType#EVT_TASK_TIMEDOUT + * @see EventType#EVTS_TASK_EXECUTION + */ +public class TaskEvent extends EventAdapter { + /** */ + private static final long serialVersionUID = 0L; + + /** */ + private final String taskName; + + /** */ + private final String taskClsName; + + /** */ + private final IgniteUuid sesId; + + /** */ + private final boolean internal; + + /** */ + private final UUID subjId; + + /** {@inheritDoc} */ + @Override public String shortDisplay() { + return name() + ": taskName=" + taskName; + } + + /** + * Creates task event with given parameters. + * + * @param node Node. + * @param msg Optional message. + * @param type Event type. + * @param sesId Task session ID. + * @param taskName Task name. + * @param subjId Subject ID. + */ + public TaskEvent(ClusterNode node, String msg, int type, IgniteUuid sesId, String taskName, String taskClsName, + boolean internal, @Nullable UUID subjId) { + super(node, msg, type); + + this.sesId = sesId; + this.taskName = taskName; + this.taskClsName = taskClsName; + this.internal = internal; + this.subjId = subjId; + } + + /** + * Gets name of the task that triggered the event. + * + * @return Name of the task that triggered the event. + */ + public String taskName() { + return taskName; + } + + /** + * Gets name of task class that triggered this event. + * + * @return Name of task class that triggered the event. + */ + public String taskClassName() { + return taskClsName; + } + + /** + * Gets session ID of the task that triggered the event. + * + * @return Session ID of the task that triggered the event. + */ + public IgniteUuid taskSessionId() { + return sesId; + } + + /** - * Returns {@code true} if task is created by GridGain and is used for system needs. ++ * Returns {@code true} if task is created by Ignite and is used for system needs. + * - * @return {@code True} if task is created by GridGain and is used for system needs. ++ * @return {@code True} if task is created by Ignite and is used for system needs. + */ + public boolean internal() { + return internal; + } + + /** + * Gets security subject ID initiated this task event, if available. This property + * is not available for GridEventType#EVT_TASK_SESSION_ATTR_SET task event. + * <p> + * Subject ID will be set either to node ID or client ID initiated + * task execution. + * + * @return Subject ID. + */ + @Nullable public UUID subjectId() { + return subjId; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(TaskEvent.class, this, + "nodeId8", U.id8(node().id()), + "msg", message(), + "type", name(), + "tstamp", timestamp()); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/ignitefs/IgniteFsGroupDataBlocksKeyMapper.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/ignitefs/IgniteFsGroupDataBlocksKeyMapper.java index 945b6a8,0000000..cefaa72 mode 100644,000000..100644 --- a/modules/core/src/main/java/org/apache/ignite/ignitefs/IgniteFsGroupDataBlocksKeyMapper.java +++ b/modules/core/src/main/java/org/apache/ignite/ignitefs/IgniteFsGroupDataBlocksKeyMapper.java @@@ -1,101 -1,0 +1,101 @@@ +/* + * 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.ignitefs; + +import org.apache.ignite.internal.processors.cache.*; +import org.apache.ignite.internal.processors.fs.*; +import org.apache.ignite.internal.util.typedef.internal.*; + +/** + * {@code GGFS} class providing ability to group file's data blocks together on one node. + * All blocks within the same group are guaranteed to be cached together on the same node. + * Group size parameter controls how many sequential blocks will be cached together on the same node. + * <p> + * For example, if block size is {@code 64kb} and group size is {@code 256}, then each group will contain + * {@code 64kb * 256 = 16Mb}. Larger group sizes would reduce number of splits required to run map-reduce + * tasks, but will increase inequality of data size being stored on different nodes. + * <p> + * Note that {@link #groupSize()} parameter must correlate to Hadoop split size parameter defined + * in Hadoop via {@code mapred.max.split.size} property. Ideally you want all blocks accessed + * within one split to be mapped to {@code 1} group, so they can be located on the same grid node. + * For example, default Hadoop split size is {@code 64mb} and default {@code GGFS} block size + * is {@code 64kb}. This means that to make sure that each split goes only through blocks on + * the same node (without hopping between nodes over network), we have to make the {@link #groupSize()} + * value be equal to {@code 64mb / 64kb = 1024}. + * <p> + * It is required for {@code GGFS} data cache to be configured with this mapper. Here is an + * example of how it can be specified in XML configuration: + * <pre name="code" class="xml"> - * <bean id="cacheCfgBase" class="org.gridgain.grid.cache.GridCacheConfiguration" abstract="true"> ++ * <bean id="cacheCfgBase" class="org.apache.ignite.cache.CacheConfiguration" abstract="true"> + * ... + * <property name="affinityMapper"> + * <bean class="org.apache.ignite.ignitefs.IgniteFsGroupDataBlocksKeyMapper"> + * <!-- How many sequential blocks will be stored on the same node. --> + * <constructor-arg value="512"/> + * </bean> + * </property> + * ... + * </bean> + * </pre> + */ +public class IgniteFsGroupDataBlocksKeyMapper extends GridCacheDefaultAffinityKeyMapper { + /** */ + private static final long serialVersionUID = 0L; + + /** Size of the group. */ + private final int grpSize; + + /*** + * Constructs affinity mapper to group several data blocks with the same key. + * + * @param grpSize Size of the group in blocks. + */ + public IgniteFsGroupDataBlocksKeyMapper(int grpSize) { + A.ensure(grpSize >= 1, "grpSize >= 1"); + + this.grpSize = grpSize; + } + + /** {@inheritDoc} */ + @Override public Object affinityKey(Object key) { + if (key != null && GridGgfsBlockKey.class.equals(key.getClass())) { + GridGgfsBlockKey blockKey = (GridGgfsBlockKey)key; + + if (blockKey.affinityKey() != null) + return blockKey.affinityKey(); + + long grpId = blockKey.getBlockId() / grpSize; + + return blockKey.getFileId().hashCode() + (int)(grpId ^ (grpId >>> 32)); + } + + return super.affinityKey(key); + } + + /** + * @return Size of the group. + */ + public int groupSize() { + return grpSize; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(IgniteFsGroupDataBlocksKeyMapper.class, this); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/ignitefs/IgniteFsInvalidHdfsVersionException.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/ignitefs/IgniteFsInvalidHdfsVersionException.java index e3fe3e2,0000000..9b08be3 mode 100644,000000..100644 --- a/modules/core/src/main/java/org/apache/ignite/ignitefs/IgniteFsInvalidHdfsVersionException.java +++ b/modules/core/src/main/java/org/apache/ignite/ignitefs/IgniteFsInvalidHdfsVersionException.java @@@ -1,42 -1,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.ignitefs; + +/** - * Exception thrown when GridGain detects that remote HDFS version differs from version of HDFS libraries - * in GridGain classpath. ++ * Exception thrown when Ignite detects that remote HDFS version differs from version of HDFS libraries ++ * in Ignite classpath. + */ +public class IgniteFsInvalidHdfsVersionException extends IgniteFsException { + /** */ + private static final long serialVersionUID = 0L; + + /** + * @param msg Error message. + */ + public IgniteFsInvalidHdfsVersionException(String msg) { + super(msg); + } + + /** + * @param msg Error message. + * @param cause Error cause. + */ + public IgniteFsInvalidHdfsVersionException(String msg, Throwable cause) { + super(msg, cause); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/ignitefs/mapreduce/package.html ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/ignitefs/mapreduce/package.html index 73667f0,0000000..330c08f mode 100644,000000..100644 --- a/modules/core/src/main/java/org/apache/ignite/ignitefs/mapreduce/package.html +++ b/modules/core/src/main/java/org/apache/ignite/ignitefs/mapreduce/package.html @@@ -1,23 -1,0 +1,24 @@@ +<!-- + 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. - --> ++--> ++ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html> +<body> + <!-- Package description. --> + Contains APIs for In-Memory MapReduce over GGFS. +</body> +</html> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/ignitefs/mapreduce/records/package.html ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/ignitefs/mapreduce/records/package.html index 947244d,0000000..6e35365 mode 100644,000000..100644 --- a/modules/core/src/main/java/org/apache/ignite/ignitefs/mapreduce/records/package.html +++ b/modules/core/src/main/java/org/apache/ignite/ignitefs/mapreduce/records/package.html @@@ -1,24 -1,0 +1,24 @@@ +<!-- + 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. - --> ++--> + +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html> +<body> + <!-- Package description. --> + Contains record resolvers for In-Memory MapReduce over GGFS. +</body> +</html> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/ignitefs/package.html ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/ignitefs/package.html index ea47d6c,0000000..c08c784 mode 100644,000000..100644 --- a/modules/core/src/main/java/org/apache/ignite/ignitefs/package.html +++ b/modules/core/src/main/java/org/apache/ignite/ignitefs/package.html @@@ -1,24 -1,0 +1,24 @@@ +<!-- + 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. - --> ++--> + +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html> +<body> + <!-- Package description. --> + Contains <b>G</b>rid<b>G</b>ain <b>F</b>ile <b>S</b>ystem APIs. +</body> +</html> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/internal/ClusterGroupAdapter.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/internal/IgniteEventsImpl.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b08492a5/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcConnection.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcConnection.java index 5d37cc7,0000000..0977600 mode 100644,000000..100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcConnection.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcConnection.java @@@ -1,547 -1,0 +1,547 @@@ +/* + * 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.jdbc; + +import org.apache.ignite.client.*; + +import java.sql.*; +import java.util.*; +import java.util.concurrent.*; + +import static java.sql.ResultSet.*; +import static java.util.concurrent.TimeUnit.*; +import static org.apache.ignite.IgniteJdbcDriver.*; + +/** + * JDBC connection implementation. + */ +public class JdbcConnection implements Connection { + /** Validation task name. */ + private static final String VALID_TASK_NAME = + "org.apache.ignite.internal.processors.cache.query.jdbc.GridCacheQueryJdbcValidationTask"; + - /** GridGain client. */ ++ /** Ignite client. */ + private final GridClient client; + + /** Cache name. */ + private String cacheName; + + /** Closed flag. */ + private boolean closed; + + /** URL. */ + private String url; + + /** Node ID. */ + private UUID nodeId; + + /** Timeout. */ + private int timeout; + + /** + * Creates new connection. + * + * @param url Connection URL. + * @param props Additional properties. - * @throws SQLException In case GridGain client failed to start. ++ * @throws SQLException In case Ignite client failed to start. + */ + public JdbcConnection(String url, Properties props) throws SQLException { + assert url != null; + assert props != null; + + this.url = url; + cacheName = props.getProperty(PROP_CACHE); + + String nodeIdProp = props.getProperty(PROP_NODE_ID); + + if (nodeIdProp != null) + nodeId = UUID.fromString(nodeIdProp); + + try { + GridClientConfiguration cfg = new GridClientConfiguration(props); + + cfg.setServers(Collections.singleton(props.getProperty(PROP_HOST) + ":" + props.getProperty(PROP_PORT))); + + // Disable all fetching and caching for metadata. + cfg.setEnableMetricsCache(false); + cfg.setEnableAttributesCache(false); + cfg.setAutoFetchMetrics(false); + cfg.setAutoFetchAttributes(false); + + client = GridClientFactory.start(cfg); + } + catch (GridClientException e) { - throw new SQLException("Failed to start GridGain client.", e); ++ throw new SQLException("Failed to start Ignite client.", e); + } + + if (!isValid(2)) + throw new SQLException("Client is invalid. Probably cache name is wrong."); + } + + /** {@inheritDoc} */ + @Override public Statement createStatement() throws SQLException { + return createStatement(TYPE_FORWARD_ONLY, CONCUR_READ_ONLY, HOLD_CURSORS_OVER_COMMIT); + } + + /** {@inheritDoc} */ + @Override public PreparedStatement prepareStatement(String sql) throws SQLException { + ensureNotClosed(); + + return prepareStatement(sql, TYPE_FORWARD_ONLY, CONCUR_READ_ONLY, HOLD_CURSORS_OVER_COMMIT); + } + + /** {@inheritDoc} */ + @Override public CallableStatement prepareCall(String sql) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Callable functions are not supported."); + } + + /** {@inheritDoc} */ + @Override public String nativeSQL(String sql) throws SQLException { + ensureNotClosed(); + + return sql; + } + + /** {@inheritDoc} */ + @Override public void setAutoCommit(boolean autoCommit) throws SQLException { + ensureNotClosed(); + + if (!autoCommit) + throw new SQLFeatureNotSupportedException("Transactions are not supported."); + } + + /** {@inheritDoc} */ + @Override public boolean getAutoCommit() throws SQLException { + ensureNotClosed(); + + return true; + } + + /** {@inheritDoc} */ + @Override public void commit() throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Transactions are not supported."); + } + + /** {@inheritDoc} */ + @Override public void rollback() throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Transactions are not supported."); + } + + /** {@inheritDoc} */ + @Override public void close() throws SQLException { + if (closed) + return; + + closed = true; + + GridClientFactory.stop(client.id(), false); + } + + /** {@inheritDoc} */ + @Override public boolean isClosed() throws SQLException { + return closed; + } + + /** {@inheritDoc} */ + @Override public DatabaseMetaData getMetaData() throws SQLException { + ensureNotClosed(); + + return new JdbcDatabaseMetadata(this); + } + + /** {@inheritDoc} */ + @Override public void setReadOnly(boolean readOnly) throws SQLException { + ensureNotClosed(); + + if (!readOnly) + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public boolean isReadOnly() throws SQLException { + ensureNotClosed(); + + return true; + } + + /** {@inheritDoc} */ + @Override public void setCatalog(String catalog) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Catalogs are not supported."); + } + + /** {@inheritDoc} */ + @Override public String getCatalog() throws SQLException { + ensureNotClosed(); + + return null; + } + + /** {@inheritDoc} */ + @Override public void setTransactionIsolation(int level) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Transactions are not supported."); + } + + /** {@inheritDoc} */ + @Override public int getTransactionIsolation() throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Transactions are not supported."); + } + + /** {@inheritDoc} */ + @Override public SQLWarning getWarnings() throws SQLException { + ensureNotClosed(); + + return null; + } + + /** {@inheritDoc} */ + @Override public void clearWarnings() throws SQLException { + ensureNotClosed(); + } + + /** {@inheritDoc} */ + @Override public Statement createStatement(int resSetType, int resSetConcurrency) throws SQLException { + return createStatement(resSetType, resSetConcurrency, HOLD_CURSORS_OVER_COMMIT); + } + + /** {@inheritDoc} */ + @Override public PreparedStatement prepareStatement(String sql, int resSetType, + int resSetConcurrency) throws SQLException { + ensureNotClosed(); + + return prepareStatement(sql, resSetType, resSetConcurrency, HOLD_CURSORS_OVER_COMMIT); + } + + /** {@inheritDoc} */ + @Override public CallableStatement prepareCall(String sql, int resSetType, + int resSetConcurrency) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Callable functions are not supported."); + } + + /** {@inheritDoc} */ + @Override public Map<String, Class<?>> getTypeMap() throws SQLException { + throw new SQLFeatureNotSupportedException("Types mapping is not supported."); + } + + /** {@inheritDoc} */ + @Override public void setTypeMap(Map<String, Class<?>> map) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Types mapping is not supported."); + } + + /** {@inheritDoc} */ + @Override public void setHoldability(int holdability) throws SQLException { + ensureNotClosed(); + + if (holdability != HOLD_CURSORS_OVER_COMMIT) + throw new SQLFeatureNotSupportedException("Invalid holdability (transactions are not supported)."); + } + + /** {@inheritDoc} */ + @Override public int getHoldability() throws SQLException { + ensureNotClosed(); + + return HOLD_CURSORS_OVER_COMMIT; + } + + /** {@inheritDoc} */ + @Override public Savepoint setSavepoint() throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Transactions are not supported."); + } + + /** {@inheritDoc} */ + @Override public Savepoint setSavepoint(String name) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Transactions are not supported."); + } + + /** {@inheritDoc} */ + @Override public void rollback(Savepoint savepoint) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Transactions are not supported."); + } + + /** {@inheritDoc} */ + @Override public void releaseSavepoint(Savepoint savepoint) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Transactions are not supported."); + } + + /** {@inheritDoc} */ + @Override public Statement createStatement(int resSetType, int resSetConcurrency, + int resSetHoldability) throws SQLException { + ensureNotClosed(); + + if (resSetType != TYPE_FORWARD_ONLY) + throw new SQLFeatureNotSupportedException("Invalid result set type (only forward is supported.)"); + + if (resSetConcurrency != CONCUR_READ_ONLY) + throw new SQLFeatureNotSupportedException("Invalid concurrency (updates are not supported)."); + + if (resSetHoldability != HOLD_CURSORS_OVER_COMMIT) + throw new SQLFeatureNotSupportedException("Invalid holdability (transactions are not supported)."); + + JdbcStatement stmt = new JdbcStatement(this); + + if (timeout > 0) + stmt.timeout(timeout); + + return stmt; + } + + /** {@inheritDoc} */ + @Override public PreparedStatement prepareStatement(String sql, int resSetType, int resSetConcurrency, + int resSetHoldability) throws SQLException { + ensureNotClosed(); + + if (resSetType != TYPE_FORWARD_ONLY) + throw new SQLFeatureNotSupportedException("Invalid result set type (only forward is supported.)"); + + if (resSetConcurrency != CONCUR_READ_ONLY) + throw new SQLFeatureNotSupportedException("Invalid concurrency (updates are not supported)."); + + if (resSetHoldability != HOLD_CURSORS_OVER_COMMIT) + throw new SQLFeatureNotSupportedException("Invalid holdability (transactions are not supported)."); + + JdbcPreparedStatement stmt = new JdbcPreparedStatement(this, sql); + + if (timeout > 0) + stmt.timeout(timeout); + + return stmt; + } + + /** {@inheritDoc} */ + @Override public CallableStatement prepareCall(String sql, int resSetType, int resSetConcurrency, + int resSetHoldability) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Callable functions are not supported."); + } + + /** {@inheritDoc} */ + @Override public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public PreparedStatement prepareStatement(String sql, int[] colIndexes) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public PreparedStatement prepareStatement(String sql, String[] colNames) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("Updates are not supported."); + } + + /** {@inheritDoc} */ + @Override public Clob createClob() throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("SQL-specific types are not supported."); + } + + /** {@inheritDoc} */ + @Override public Blob createBlob() throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("SQL-specific types are not supported."); + } + + /** {@inheritDoc} */ + @Override public NClob createNClob() throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("SQL-specific types are not supported."); + } + + /** {@inheritDoc} */ + @Override public SQLXML createSQLXML() throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("SQL-specific types are not supported."); + } + + /** {@inheritDoc} */ + @Override public boolean isValid(int timeout) throws SQLException { + ensureNotClosed(); + + if (timeout < 0) + throw new SQLException("Invalid timeout: " + timeout); + + try { + return client.compute().<Boolean>executeAsync(VALID_TASK_NAME, cacheName).get(timeout, SECONDS); + } + catch (GridClientDisconnectedException | GridClientFutureTimeoutException e) { + throw new SQLException("Failed to establish connection.", e); + } + catch (GridClientException ignored) { + return false; + } + } + + /** {@inheritDoc} */ + @Override public void setClientInfo(String name, String val) throws SQLClientInfoException { + throw new UnsupportedOperationException("Client info is not supported."); + } + + /** {@inheritDoc} */ + @Override public void setClientInfo(Properties props) throws SQLClientInfoException { + throw new UnsupportedOperationException("Client info is not supported."); + } + + /** {@inheritDoc} */ + @Override public String getClientInfo(String name) throws SQLException { + ensureNotClosed(); + + return null; + } + + /** {@inheritDoc} */ + @Override public Properties getClientInfo() throws SQLException { + ensureNotClosed(); + + return new Properties(); + } + + /** {@inheritDoc} */ + @Override public Array createArrayOf(String typeName, Object[] elements) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("SQL-specific types are not supported."); + } + + /** {@inheritDoc} */ + @Override public Struct createStruct(String typeName, Object[] attrs) throws SQLException { + ensureNotClosed(); + + throw new SQLFeatureNotSupportedException("SQL-specific types are not supported."); + } + + /** {@inheritDoc} */ + @Override public <T> T unwrap(Class<T> iface) throws SQLException { + if (!isWrapperFor(iface)) + throw new SQLException("Connection is not a wrapper for " + iface.getName()); + + return (T)this; + } + + /** {@inheritDoc} */ + @Override public boolean isWrapperFor(Class<?> iface) throws SQLException { + return iface != null && iface == Connection.class; + } + + /** {@inheritDoc} */ + @Override public void setSchema(String schema) throws SQLException { + cacheName = schema; + } + + /** {@inheritDoc} */ + @Override public String getSchema() throws SQLException { + return cacheName; + } + + /** {@inheritDoc} */ + @Override public void abort(Executor executor) throws SQLException { + close(); + } + + /** {@inheritDoc} */ + @Override public void setNetworkTimeout(Executor executor, int ms) throws SQLException { + if (ms < 0) + throw new IllegalArgumentException("Timeout is below zero: " + ms); + + timeout = ms; + } + + /** {@inheritDoc} */ + @Override public int getNetworkTimeout() throws SQLException { + return timeout; + } + + /** - * @return GridGain client. ++ * @return Ignite client. + */ + GridClient client() { + return client; + } + + /** + * @return Cache name. + */ + String cacheName() { + return cacheName; + } + + /** + * @return URL. + */ + String url() { + return url; + } + + /** + * @return Node ID. + */ + UUID nodeId() { + return nodeId; + } + + /** + * Ensures that connection is not closed. + * + * @throws SQLException If connection is closed. + */ + private void ensureNotClosed() throws SQLException { + if (closed) + throw new SQLException("Connection is closed."); + } + + /** + * @return Internal statement. + * @throws SQLException In case of error. + */ + JdbcStatement createStatement0() throws SQLException { + return (JdbcStatement)createStatement(); + } +}
