/** * @param e Link error. * @return Wrapping grid exception. */ static GridException linkError(UnsatisfiedLinkError e) { return new GridException("Linkage error due to possible native library, libggshmem.so, " + "version mismatch (stop all grid nodes, clean up your '/tmp' folder, and try again).", e); }
/** * @param err Creation error. * @return Component creation exception. */ private GridException componentException(Exception err) { return new GridException("Failed to create GridGain component (consider adding " + module + " module to classpath) [component=" + this + ", cls=" + clsName + ']', err); } }
@Override public void execute() throws GridException { try { out.write(data); } catch (IOException e) { throw new GridException("Failed to write data to the file due to secondary file system " + "exception: " + path, e); } } });
/** {@inheritDoc} */ @Override protected void readData(DataInput src, byte[] dst, int dstOff) throws GridException { try { src.readFully(dst, dstOff, dst.length - dstOff); } catch (IOException e) { throw new GridException(e); } } }
@Override public void execute() throws GridException { try { out.write(data); } catch (IOException e) { throw new GridException("Failed to write data to the file due to secondary file system " + "exception: " + path, e); } } });
@Override public GridGgfsFileInfo onFailure(@Nullable Exception err) throws GridException { U.error(log, "Path update in DUAL mode failed [path=" + path + ", properties=" + props + ']', err); throw new GridException("Failed to update the path due to secondary file system exception: " + path, err); } };
/** {@inheritDoc} */ @Override public R get() throws GridException { try { if (doneLatch.getCount() > 0) doneLatch.await(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new GridException("Operation was interrupted.", e); } return getResult(); }
@Override public Boolean onFailure(@Nullable Exception err) throws GridException { U.error(log, "Directory creation in DUAL mode failed [path=" + path + ", properties=" + props + ']', err); throw new GridException("Failed to create the path due to secondary file system exception: " + path, err); } };
@Override public GridGgfsFileInfo onFailure(@Nullable Exception err) throws GridException { U.error(log, "Path update in DUAL mode failed [path=" + path + ", properties=" + props + ']', err); throw new GridException("Failed to update the path due to secondary file system exception: " + path, err); } };
/** * @param grid Grid instance. * @param cacheName Name of the cache. * @return Instance on the named cache. * @throws GridException If cache not found. */ private static GridCacheProjectionEx<Object, Object> cache(Grid grid, String cacheName) throws GridException { GridCache<Object, Object> cache = grid.cache(cacheName); if (cache == null) throw new GridException( "Failed to find cache for given cache name (null for default cache): " + cacheName); return (GridCacheProjectionEx<Object, Object>)cache; }
@Override public GridGgfsSecondaryOutputStreamDescriptor onFailure(@Nullable Exception err) throws GridException { U.closeQuiet(out); U.error(log, "File append in DUAL mode failed [path=" + path + ", bufferSize=" + bufSize + ']', err); if (err instanceof GridGgfsException) throw (GridGgfsException)err; else throw new GridException("Failed to append to the file due to secondary file system " + "exception: " + path, err); } };
/** * @throws GridException If failed. */ public synchronized void delete() throws GridException { U.close(readCh, log); U.close(writeCh, log); try { Files.deleteIfExists(file); } catch (IOException e) { throw new GridException(e); } }
/** {@inheritDoc} */ @Override public R reduce(List<GridComputeJobResult> res) throws GridException { for (GridComputeJobResult r : res) if (r.getException() == null) return r.getData(); throw new GridException("Failed to find successful job result: " + res); } }
/** {@inheritDoc} */ @Override protected Void run(Set<String> ggfsNames) throws GridException { for (String ggfsName: ggfsNames) try { g.ggfs(ggfsName).resetMetrics(); } catch (IllegalArgumentException iae) { throw new GridException("Failed to reset metrics for GGFS: " + ggfsName, iae); } return null; }
/** {@inheritDoc} */ @Override protected Void run(String ggfsName) throws GridException { try { g.ggfs(ggfsName).format().get(); } catch (IllegalArgumentException iae) { throw new GridException("Failed to format GGFS: " + ggfsName, iae); } return null; }
/** {@inheritDoc} */ @Override protected void onKernalStart0() throws GridException { if (intLsnrCnt.get() > 0 || lsnrCnt.get() > 0) { Collection<GridNode> nodes = cctx.discovery().cacheNodes(cctx.name(), -1); for (GridNode n : nodes) { if (!n.version().greaterThanEqual(6, 2, 0)) throw new GridException("Rolling update is not supported for continuous queries " + "for versions below 6.2.0"); } } }
/** {@inheritDoc} */ @Override public void validateCacheConfiguration(GridCacheConfiguration cfg) throws GridException { GridCacheEvictionPolicy evictPlc = cfg.getEvictionPolicy(); if (evictPlc != null && evictPlc instanceof GridCacheGgfsPerBlockLruEvictionPolicy) { GridCacheEvictionFilter evictFilter = cfg.getEvictionFilter(); if (evictFilter != null && !(evictFilter instanceof GridCacheGgfsEvictionFilter)) throw new GridException("Eviction filter cannot be set explicitly when using " + "GridCacheGgfsPerBlockLruEvictionPolicy:" + cfg.getName()); } }
/** * @throws GridException If query is invalid. */ public void validate() throws GridException { if (type != SCAN && !cctx.config().isQueryIndexEnabled()) throw new GridException("Indexing is disabled for cache: " + cctx.cache().name()); }
/** * @throws GridException If {@link GridCacheQueue} can not be used with current cache configuration. */ private void checkSupportsQueue() throws GridException { if (cctx.atomic() && !cctx.isLocal() && cctx.config().getAtomicWriteOrderMode() == CLOCK) throw new GridException("GridCacheQueue can not be used with ATOMIC cache with CLOCK write order mode" + " (change write order mode to PRIMARY in configuration)"); }
/** {@inheritDoc} */ @Override public void start() throws GridException { if (ctx.isDaemon()) return; GridConfiguration cfg = ctx.config(); GridDeploymentMode depMode = cfg.getDeploymentMode(); if (cfg.isPeerClassLoadingEnabled() && (depMode == PRIVATE || depMode == ISOLATED) && !F.isEmpty(cfg.getServiceConfiguration())) throw new GridException("Cannot deploy services in PRIVATE or ISOLATED deployment mode: " + depMode); }