/** {@inheritDoc} */ @Override public IgniteFileSystem fileSystem(String name) { checkIgnite(); return g.fileSystem(name); }
/** {@inheritDoc} */ @Override public final T call() throws Exception { assert ignite != null; final IgfsEx igfs = (IgfsEx)ignite.fileSystem(igfsName); if (user != null) { return IgfsUserContext.doAs(user, new Callable<T>() { @Override public T call() throws Exception { return call0(igfs.context()); } }); } else return call0(igfs.context()); }
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { chunk = new byte[128]; for (int i = 0; i < chunk.length; i++) chunk[i] = (byte)i; Ignite igniteSecondary = startGridWithIgfs("grid-secondary", "igfs-secondary", PRIMARY, null, SECONDARY_REST_CFG); IgfsSecondaryFileSystem hadoopFs = new IgniteHadoopIgfsSecondaryFileSystem(SECONDARY_URI, SECONDARY_CFG); Ignite ignite = startGridWithIgfs("grid", "igfs", mode, hadoopFs, PRIMARY_REST_CFG); igfsSecondary = (IgfsImpl) igniteSecondary.fileSystem("igfs-secondary"); igfs = (IgfsImpl) ignite.fileSystem("igfs"); }
/** * Start a grid with the primary file system. * * @throws Exception If failed. */ private void startPrimary() throws Exception { igfsPrimary = new IgniteFileSystem[NODES_CNT]; for (int i = 0; i < NODES_CNT; i++) { Ignite g = G.start(primaryConfiguration(i)); igfsPrimary[i] = g.fileSystem(IGFS_PRIMARY); } }
/** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { for (int i = 0; i < NODE_CNT; i++) { Ignite g = G.start(config(i)); if (i + 1 == NODE_CNT) igfs = g.fileSystem("igfs"); } }
@Override public Void call() throws Exception { IgniteFileSystem igfs = attacker.fileSystem(IGFS_NAME); try (IgfsOutputStream out = igfs.create(path, true)) { writeStartLatch.await(); out.write(new byte[1024]); out.flush(); } return null; } });
/** * Perform startup. * * @param dfltIgniteInstanceName Default Ignite instance name. * @param dfltIgfsName Default IGFS name. * @throws Exception If failed. */ private void startUp(boolean dfltIgniteInstanceName, boolean dfltIgfsName) throws Exception { Ignite ignite = G.start(gridConfiguration(dfltIgniteInstanceName)); IgniteFileSystem igfs = ignite.fileSystem(dfltIgfsName ? "" : IGFS_NAME); igfs.mkdirs(PATH); }
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { super.beforeTest(); igfs = (IgfsEx)startGrids(gridCount()).fileSystem(igfsName); }
/** * Creates secondary file system stack. * * @return The secondary file system. * @throws Exception On error. */ protected IgfsSecondaryFileSystem createSecondaryFileSystemStack() throws Exception { Ignite igniteSecondary = startGridWithIgfs("ignite-secondary", "igfs-secondary", PRIMARY, null, SECONDARY_REST_CFG, secondaryIpFinder); IgfsEx secondaryIgfsImpl = (IgfsEx) igniteSecondary.fileSystem("igfs-secondary"); igfsSecondary = new DefaultIgfsSecondaryFileSystemTestAdapter(secondaryIgfsImpl); return secondaryIgfsImpl.asSecondary(); }
/** * Start a grid with the secondary file system. * * @return Secondary file system handle. * @throws Exception If failed. */ @Nullable private IgniteFileSystem startSecondary() throws Exception { IgniteConfiguration cfg = getConfiguration("grid-secondary", getSecondaryIgfsConfiguration()); cfg.setLocalHost("127.0.0.1"); cfg.setPeerClassLoadingEnabled(false); Ignite secG = G.start(cfg); return secG.fileSystem("igfs-secondary"); } }
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { beforeHadoopCommandLineTest(); String cfgPath = "config/hadoop/default-config.xml"; IgniteBiTuple<IgniteConfiguration, GridSpringResourceContext> tup = IgnitionEx.loadConfiguration(cfgPath); IgniteConfiguration cfg = tup.get1(); cfg.setLocalHost("127.0.0.1"); // Avoid connecting to other nodes. igfs = (IgfsEx) Ignition.start(cfg).fileSystem(igfsName); }
/** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { igfsSecondaryFileSystem = createSecondaryFileSystemStack(); nodes = new Ignite[nodeCount()]; for (int i = 0; i < nodes.length; i++) { String nodeName = i == 0 ? "ignite" : "ignite" + i; nodes[i] = startGridWithIgfs(nodeName, "igfs", mode, igfsSecondaryFileSystem, PRIMARY_REST_CFG, primaryIpFinder); } igfs = (IgfsImpl) nodes[0].fileSystem("igfs"); if (client()) { // Start client. Ignition.setClientMode(true); try { Ignite ignite = startGridWithIgfs("ignite-client", "igfs", mode, igfsSecondaryFileSystem, PRIMARY_REST_CFG, primaryIpFinder); igfs = (IgfsImpl) ignite.fileSystem("igfs"); } finally { Ignition.setClientMode(false); } } }
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { super.beforeTest(); nodeDatas = new NodeFsData[numIgfsNodes]; for (int i = 0; i<numIgfsNodes; i++) { NodeFsData data = new NodeFsData(); data.idx = i; data.ignite = startGridWithIgfs(getTestIgniteInstanceName(i), igfsMode, null); data.igfsImpl = (IgfsImpl) data.ignite.fileSystem("igfs"); nodeDatas[i] = data; } // Ensure all the nodes are started and discovered each other: checkTopology(numIgfsNodes); }
/** {@inheritDoc} */ @Override public Object execute() { IgniteFileSystem fs = ignite.fileSystem(igfsName); try (IgfsInputStream in = fs.open(path)) { IgfsFileRange split = new IgfsFileRange(path, start, len); if (rslvr != null) { split = rslvr.resolveRecords(fs, in, split); if (split == null) { log.warning("No data found for split on local node after resolver is applied " + "[igfsName=" + igfsName + ", path=" + path + ", start=" + start + ", len=" + len + ']'); return null; } } in.seek(split.start()); return job.execute(fs, new IgfsFileRange(path, split.start(), split.length()), in); } catch (IOException e) { throw new IgniteException("Failed to execute IGFS job for file split [igfsName=" + igfsName + ", path=" + path + ", start=" + start + ", len=" + len + ']', e); } }
/** * @throws Exception If failed. */ @Test public void testInjectPrimaryByField() throws Exception { secondary = new TestBaseSecondaryFsMock() { @FileSystemResource private IgfsImpl igfs; @LoggerResource private IgniteLogger log; @IgniteInstanceResource private Ignite ig; @Override boolean checkInjection(Ignite ignite, IgniteFileSystem primary) { return igfs == primary && log instanceof IgniteLogger && ig == ignite; } }; Ignite ig = startGrid(0); IgniteFileSystem igfs = ig.fileSystem(IGFS_NAME); assert secondary.checkInjection(ig, igfs); }
/** * @throws Exception If failed. */ @Test public void testCacheStart() throws Exception { Ignite g0 = G.start(config(true, 0)); String dataCacheName = ((IgniteEx)g0).igfsx("igfs").configuration().getDataCacheConfiguration().getName(); String metaCacheName = ((IgniteEx)g0).igfsx("igfs").configuration().getMetaCacheConfiguration().getName(); checkIgfsCaches(g0, dataCacheName, metaCacheName); Ignite g1 = G.start(config(false, 1)); checkIgfsCaches(g1, dataCacheName, metaCacheName); IgniteFileSystem igfs = g0.fileSystem("igfs"); igfs.mkdirs(new IgfsPath("/test")); try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(igfs.create( new IgfsPath("/test/test.file"), true)))) { for (int i = 0; i < 1000; i++) bw.write("test-" + i); } }
/** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { FileSystemConfiguration igfsCfg = new FileSystemConfiguration(); igfsCfg.setName("igfs"); igfsCfg.setBlockSize(512); igfsCfg.setDefaultMode(PRIMARY); CacheConfiguration dataCacheCfg = new CacheConfiguration(DEFAULT_CACHE_NAME); dataCacheCfg.setCacheMode(PARTITIONED); dataCacheCfg.setAtomicityMode(TRANSACTIONAL); dataCacheCfg.setNearConfiguration(new NearCacheConfiguration()); dataCacheCfg.setWriteSynchronizationMode(FULL_SYNC); dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(128)); dataCacheCfg.setBackups(0); CacheConfiguration metaCacheCfg = new CacheConfiguration(DEFAULT_CACHE_NAME); metaCacheCfg.setCacheMode(REPLICATED); metaCacheCfg.setAtomicityMode(TRANSACTIONAL); metaCacheCfg.setWriteSynchronizationMode(FULL_SYNC); igfsCfg.setMetaCacheConfiguration(metaCacheCfg); igfsCfg.setDataCacheConfiguration(dataCacheCfg); IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setIgniteInstanceName("grid"); cfg.setFileSystemConfiguration(igfsCfg); Ignite g = G.start(cfg); igfs = g.fileSystem("igfs"); }
igfsSecondary = (IgfsImpl)g.fileSystem(IGFS_SECONDARY);
cfg.setConnectorConfiguration(null); igfsSecondary = (IgfsImpl)G.start(cfg).fileSystem("igfs-secondary");
secondaryFs = (IgfsImpl)g.fileSystem(IGFS_SECONDARY);