org.gridgain.grid.spi.failover.never.GridNeverFailoverSpi Maven / Gradle / Ivy
/*
Copyright (C) GridGain Systems. All Rights Reserved.
Licensed 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.gridgain.grid.spi.failover.never;
import org.gridgain.grid.*;
import org.gridgain.grid.logger.*;
import org.gridgain.grid.resources.*;
import org.gridgain.grid.spi.*;
import org.gridgain.grid.spi.failover.*;
import org.gridgain.grid.util.typedef.internal.*;
import java.util.*;
/**
* This class provides failover SPI implementation that never fails over. This implementation
* never fails over a failed job by always returning {@code null} out of
* {@link GridFailoverSpi#failover(GridFailoverContext, List)} method.
* Configuration
* Mandatory
* This SPI has no mandatory configuration parameters.
* Optional
* This SPI has no optional configuration parameters.
*
* Here is a Java example on how to configure grid with {@code GridNeverFailoverSpi}:
*
* GridNeverFailoverSpi spi = new GridNeverFailoverSpi();
*
* GridConfiguration cfg = new GridConfiguration();
*
* // Override default failover SPI.
* cfg.setFailoverSpiSpi(spi);
*
* // Starts grid.
* G.start(cfg);
*
* Here is an example on how to configure grid with {@code GridNeverFailoverSpi} from Spring XML configuration file:
*
* <property name="failoverSpi">
* <bean class="org.gridgain.grid.spi.failover.never.GridNeverFailoverSpi"/>
* </property>
*
*
*
*
* For information about Spring framework visit www.springframework.org
* @see GridFailoverSpi
*/
@GridSpiInfo(
author = /*@java.spi.author*/"GridGain Systems",
url = /*@java.spi.url*/"www.gridgain.com",
email = /*@java.spi.email*/"[email protected]",
version = /*@java.spi.version*/"x.x")
@GridSpiMultipleInstancesSupport(true)
public class GridNeverFailoverSpi extends GridSpiAdapter implements GridFailoverSpi, GridNeverFailoverSpiMBean {
/** Injected grid logger. */
@GridLoggerResource private GridLogger log;
/** {@inheritDoc} */
@Override public void spiStart(String gridName) throws GridSpiException {
// Start SPI start stopwatch.
startStopwatch();
registerMBean(gridName, this, GridNeverFailoverSpiMBean.class);
// Ack ok start.
if (log.isDebugEnabled()) {
log.debug(startInfo());
}
}
/** {@inheritDoc} */
@Override public void spiStop() throws GridSpiException {
unregisterMBean();
// Ack ok stop.
if (log.isDebugEnabled()) {
log.debug(stopInfo());
}
}
/** {@inheritDoc} */
@Override public GridNode failover(GridFailoverContext ctx, List top) {
U.warn(log, "Returning 'null' node for failed job (failover will not happen) [job=" +
ctx.getJobResult().getJob() + ", task=" + ctx.getTaskSession().getTaskName() +
", sessionId=" + ctx.getTaskSession().getId() + ']');
return null;
}
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(GridNeverFailoverSpi.class, this);
}
}