本文整理匯總了Java中org.apache.ignite.spi.IgniteSpiException類的典型用法代碼示例。如果您正苦於以下問題:Java IgniteSpiException類的具體用法?Java IgniteSpiException怎麽用?Java IgniteSpiException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IgniteSpiException類屬於org.apache.ignite.spi包,在下文中一共展示了IgniteSpiException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getRegisteredAddresses
import org.apache.ignite.spi.IgniteSpiException; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
public Collection<InetSocketAddress> getRegisteredAddresses() throws IgniteSpiException {
init();
if (log.isDebugEnabled())
log.debug("Getting registered addresses from Redis IP Finder.");
Collection<String> addresses;
try(Jedis jedis = new Jedis("redis://" + redisConnectionString)) {
addresses = jedis.smembers(addressesSetKey());
} catch (JedisException e) {
log.warning("Error while getting registered addresses from Redis IP Finder.", e);
return Collections.emptyList();
}
Set<InetSocketAddress> answer = new HashSet<>();
for (String address : addresses) {
answer.add(deserializeAddress(address));
}
if (log.isInfoEnabled())
log.info("Redis IP Finder resolved addresses: " + answer);
return answer;
}
示例2: registerAddresses
import org.apache.ignite.spi.IgniteSpiException; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
public void registerAddresses(Collection<InetSocketAddress> addresses) throws IgniteSpiException {
init();
if (log.isInfoEnabled())
log.info("Registering addresses with Redis IP Finder: " + addresses);
Collection<String> serializedAddresses = new HashSet<>();
for (InetSocketAddress address : addresses) {
serializedAddresses.add(serializeAddress(address));
}
try(Jedis jedis = new Jedis("redis://" + redisConnectionString)) {
String[] sAddresses = serializedAddresses.toArray(new String[serializedAddresses.size()]);
jedis.sadd(addressesSetKey(), sAddresses);
} catch (JedisException e) {
log.warning(String.format("Error while registering an address from Redis IP Finder " +
"[message=%s,addresses=%s]", e.getMessage(), addresses), e);
}
}
示例3: spiStart
import org.apache.ignite.spi.IgniteSpiException; //導入依賴的package包/類
/** {@inheritDoc} */
@Override public void spiStart(@Nullable String igniteInstanceName) throws IgniteSpiException {
startStopwatch();
assertParameter(nodeWeight > 0, "nodeWeight > 0");
if (log.isDebugEnabled()) {
log.debug(configInfo("isUseWeights", isUseWeights));
log.debug(configInfo("nodeWeight", nodeWeight));
}
registerMBean(igniteInstanceName, new WeightedRandomLoadBalancingSpiMBeanImpl(this),
WeightedRandomLoadBalancingSpiMBean.class);
// Ack ok start.
if (log.isDebugEnabled())
log.debug(startInfo());
}
示例4: spiStop
import org.apache.ignite.spi.IgniteSpiException; //導入依賴的package包/類
/** {@inheritDoc} */
@Override public void spiStop() throws IgniteSpiException {
rwLock.writeLock().lock();
try {
nodeJobs.clear();
}
finally {
rwLock.writeLock().unlock();
}
unregisterMBean();
// Ack ok stop.
if (log.isDebugEnabled())
log.debug(stopInfo());
}
示例5: spiStop
import org.apache.ignite.spi.IgniteSpiException; //導入依賴的package包/類
/** {@inheritDoc} */
@Override public void spiStop() throws IgniteSpiException {
if (ctxInitLatch.getCount() > 0)
// Safety.
ctxInitLatch.countDown();
if (ipFinder != null) {
try {
ipFinder.close();
}
catch (Exception e) {
log.error("Failed to close ipFinder", e);
}
}
unregisterMBean();
if (impl != null)
impl.spiStop();
}
示例6: unregisterAddresses
import org.apache.ignite.spi.IgniteSpiException; //導入依賴的package包/類
/** {@inheritDoc} */
@Override public void unregisterAddresses(Collection<InetSocketAddress> addrs) throws IgniteSpiException {
assert !F.isEmpty(addrs);
initClient();
for (InetSocketAddress addr : addrs) {
String key = key(addr);
try {
s3.deleteObject(bucketName, key);
}
catch (AmazonClientException e) {
throw new IgniteSpiException("Failed to delete entry [bucketName=" + bucketName +
", entry=" + key + ']', e);
}
}
}
示例7: spiStart
import org.apache.ignite.spi.IgniteSpiException; //導入依賴的package包/類
/** {@inheritDoc} */
@Override public void spiStart(@Nullable String igniteInstanceName) throws IgniteSpiException {
startStopwatch();
assertParameter(probe != null, "loadProbe != null");
if (log.isDebugEnabled())
log.debug(configInfo("loadProbe", probe));
registerMBean(igniteInstanceName, new AdaptiveLoadBalancingSpiMBeanImpl(this),
AdaptiveLoadBalancingSpiMBean.class);
// Ack ok start.
if (log.isDebugEnabled())
log.debug(startInfo());
}
示例8: query
import org.apache.ignite.spi.IgniteSpiException; //導入依賴的package包/類
/** {@inheritDoc} */
@Override public Iterator<Cache.Entry<?, ?>> query(@Nullable String cacheName, Collection<Object> params,
@Nullable IndexingQueryFilter filters) throws IgniteSpiException {
if (params.size() < 2)
throw new IgniteSpiException("Range parameters required.");
Iterator<Object> paramsIt = params.iterator();
Object from = paramsIt.next();
Object to = paramsIt.next();
from = from instanceof BinaryObject ? ((BinaryObject)from).deserialize() : from;
to = to instanceof BinaryObject ? ((BinaryObject)to).deserialize() : to;
SortedMap<Object, Object> map = idx.subMap(from, to);
Collection<Cache.Entry<?, ?>> res = new ArrayList<>(map.size());
for (Map.Entry<Object, Object> entry : map.entrySet())
res.add(new CacheEntryImpl<>(entry.getKey(), entry.getValue()));
return res.iterator();
}
示例9: sendMessage
import org.apache.ignite.spi.IgniteSpiException; //導入依賴的package包/類
/** {@inheritDoc} */
@Override public void sendMessage(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackC)
throws IgniteSpiException {
if (msg instanceof GridIoMessage) {
Object msg0 = ((GridIoMessage)msg).message();
synchronized (this) {
if (recordCls != null && msg0.getClass().equals(recordCls))
recordedMsgs.add(msg0);
Set<UUID> blockNodes = blockCls.get(msg0.getClass());
if (F.contains(blockNodes, node.id())) {
log.info("Block message [node=" +
node.attribute(IgniteNodeAttributes.ATTR_IGNITE_INSTANCE_NAME) + ", msg=" + msg0 + ']');
blockedMsgs.add(new T2<>(node, (GridIoMessage)msg));
return;
}
}
}
super.sendMessage(node, msg, ackC);
}
示例10: sendMessage0
import org.apache.ignite.spi.IgniteSpiException; //導入依賴的package包/類
/**
* Send message optionally either blocking it or throwing an exception if it is of
* {@link GridJobExecuteResponse} type.
*
* @param node Destination node.
* @param msg Message to be sent.
* @param ackClosure Ack closure.
* @throws org.apache.ignite.spi.IgniteSpiException If failed.
*/
private void sendMessage0(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackClosure)
throws IgniteSpiException {
if (msg instanceof GridIoMessage) {
GridIoMessage msg0 = (GridIoMessage)msg;
if (msg0.message() instanceof GridJobExecuteResponse) {
respLatch.countDown();
if (wait) {
try {
U.await(waitLatch);
}
catch (IgniteInterruptedCheckedException ignore) {
// No-op.
}
}
}
}
if (!block)
super.sendMessage(node, msg, ackClosure);
}
示例11: initializeTemporaryDirectoryPath
import org.apache.ignite.spi.IgniteSpiException; //導入依賴的package包/類
/**
* Initializes temporary directory path. Path consists of base path
* (either {@link #tmpDirPath} value or {@code java.io.tmpdir}
* system property value if first is {@code null}) and path relative
* to base one - {@link #DEPLOY_TMP_ROOT_NAME}/{@code local node ID}.
*
* @throws org.apache.ignite.spi.IgniteSpiException Thrown if temporary directory could not be created.
*/
private void initializeTemporaryDirectoryPath() throws IgniteSpiException {
String tmpDirPath = this.tmpDirPath == null ? System.getProperty("java.io.tmpdir") : this.tmpDirPath;
if (tmpDirPath == null)
throw new IgniteSpiException("Error initializing temporary deployment directory.");
File dir = new File(tmpDirPath + File.separator + DEPLOY_TMP_ROOT_NAME + File.separator +
ignite.configuration().getNodeId());
if (!U.mkdirs(dir))
throw new IgniteSpiException("Error initializing temporary deployment directory: " + dir);
if (!dir.isDirectory())
throw new IgniteSpiException("Temporary deployment directory path is not a valid directory: " + dir);
if (!dir.canRead() || !dir.canWrite())
throw new IgniteSpiException("Can not write to or read from temporary deployment directory: " + dir);
this.tmpDirPath = tmpDirPath;
deployTmpDirPath = dir.getPath();
}
示例12: parseTasksDocument
import org.apache.ignite.spi.IgniteSpiException; //導入依賴的package包/類
/**
* Converts given input stream expecting XML inside to
* {@link GridUriDeploymentSpringDocument}.
* <p>
* This is a workaround for the {@link InputStreamResource} which does
* not work properly.
*
* @param in Input stream with XML.
* @param log Logger
* @return Grid wrapper for the input stream.
* @throws org.apache.ignite.spi.IgniteSpiException Thrown if incoming input stream could not be
* read or parsed by {@code Spring} {@link XmlBeanFactory}.
* @see XmlBeanFactory
*/
static GridUriDeploymentSpringDocument parseTasksDocument(InputStream in, IgniteLogger log) throws
IgniteSpiException {
assert in != null;
// Note: use ByteArrayResource instead of InputStreamResource because InputStreamResource doesn't work.
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
U.copy(in, out);
XmlBeanFactory factory = new XmlBeanFactory(new ByteArrayResource(out.toByteArray()));
return new GridUriDeploymentSpringDocument(factory);
}
catch (BeansException | IOException e) {
throw new IgniteSpiException("Failed to parse spring XML file.", e);
}
finally{
U.close(out, log);
}
}
示例13: getConfiguration
import org.apache.ignite.spi.IgniteSpiException; //導入依賴的package包/類
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
cfg.setCommunicationSpi(new TcpCommunicationSpi() {
@Override public void sendMessage(ClusterNode node, Message msg,
IgniteInClosure<IgniteException> ackClosure) throws IgniteSpiException {
if (!F.eq(ignoreMsgNodeId, node.id()) || !ignoredMessage((GridIoMessage)msg))
super.sendMessage(node, msg, ackClosure);
}
});
cfg.getTransactionConfiguration().setDefaultTxConcurrency(OPTIMISTIC);
return cfg;
}
示例14: getCredentialFromFile
import org.apache.ignite.spi.IgniteSpiException; //導入依賴的package包/類
/**
* Reads credential info from {@link #credentialPath} and returns in a string format.
*
* @return Credential in {@code String} representation.
* @throws IgniteSpiException In case of error.
*/
private String getCredentialFromFile() throws IgniteSpiException {
try {
String fileContents = Files.toString(new File(credentialPath), Charsets.UTF_8);
if (provider.equals("google-compute-engine")) {
Supplier<Credentials> credentialSupplier = new GoogleCredentialsFromJson(fileContents);
return credentialSupplier.get().credential;
}
return fileContents;
}
catch (IOException e) {
throw new IgniteSpiException("Failed to retrieve the private key from the file: " + credentialPath, e);
}
}
示例15: unregisterAddresses
import org.apache.ignite.spi.IgniteSpiException; //導入依賴的package包/類
/** {@inheritDoc} */
@Override public void unregisterAddresses(Collection<InetSocketAddress> addrs) throws IgniteSpiException {
assert !F.isEmpty(addrs);
init();
for (InetSocketAddress addr : addrs) {
String key = keyFromAddr(addr);
try {
Storage.Objects.Delete deleteObject = storage.objects().delete(bucketName, key);
deleteObject.execute();
}
catch (Exception e) {
throw new IgniteSpiException("Failed to delete entry [bucketName=" + bucketName +
", entry=" + key + ']', e);
}
}
}