use of org.apache.ignite.configuration.IgniteConfiguration in project ignite by apache.
the class HadoopIgfsInProc method create.
/**
* Creates instance of the HadoopIgfsInProcWithIgniteRefsCount by IGFS name, ignite client node is created
* if necessary.
*
* @param igniteCfgPath Path to ignite configuration.
* @param igfsName Target IGFS name.
* @param log Log.
* @param userName User name.
* @return HadoopIgfsInProcWithIgniteRefsCount instance. {@code null} if the IGFS not fount in the current VM.
* @throws IgniteCheckedException On error.
*/
public static HadoopIgfsInProc create(String igniteCfgPath, String igfsName, Log log, String userName) throws IgniteCheckedException {
IgniteBiTuple<IgniteConfiguration, GridSpringResourceContext> cfgPair = IgnitionEx.loadConfiguration(igniteCfgPath);
IgniteConfiguration cfg = cfgPair.get1();
cfg.setClientMode(true);
String nodeName = cfg.getIgniteInstanceName();
synchronized (REF_CTR_MUX) {
T2<Ignite, Boolean> startRes = IgnitionEx.getOrStart(cfg);
boolean newNodeStarted = startRes.get2();
if (newNodeStarted) {
assert !REF_CTRS.containsKey(nodeName) : "The ignite instance already exists in the ref count map";
REF_CTRS.put(nodeName, 0);
}
HadoopIgfsInProc hadoop = create0(startRes.get1(), igfsName, log, userName);
if (hadoop == null) {
if (newNodeStarted) {
REF_CTRS.remove(nodeName);
Ignition.stop(nodeName, true);
}
throw new HadoopIgfsCommunicationException("Ignite client node doesn't have IGFS with the " + "given name: " + igfsName);
}
return hadoop;
}
}
use of org.apache.ignite.configuration.IgniteConfiguration in project ignite by apache.
the class FlinkIgniteSinkSelfTest method beforeTest.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
protected void beforeTest() throws Exception {
IgniteConfiguration cfg = loadConfiguration(GRID_CONF_FILE);
cfg.setClientMode(false);
ignite = startGrid("igniteServerNode", cfg);
}
use of org.apache.ignite.configuration.IgniteConfiguration in project ignite by apache.
the class IgfsProcessor method start.
/**
* {@inheritDoc}
*/
@Override
public void start() throws IgniteCheckedException {
IgniteConfiguration igniteCfg = ctx.config();
if (igniteCfg.isDaemon())
return;
FileSystemConfiguration[] cfgs = igniteCfg.getFileSystemConfiguration();
assert cfgs != null && cfgs.length > 0;
// Start IGFS instances.
for (FileSystemConfiguration cfg : cfgs) {
assert cfg.getName() != null;
FileSystemConfiguration cfg0 = new FileSystemConfiguration(cfg);
boolean metaClient = true;
CacheConfiguration[] cacheCfgs = igniteCfg.getCacheConfiguration();
String metaCacheName = cfg.getMetaCacheConfiguration().getName();
if (cacheCfgs != null) {
for (CacheConfiguration cacheCfg : cacheCfgs) {
if (F.eq(cacheCfg.getName(), metaCacheName)) {
metaClient = false;
break;
}
}
}
if (igniteCfg.isClientMode() != null && igniteCfg.isClientMode())
metaClient = true;
IgfsContext igfsCtx = new IgfsContext(ctx, cfg0, new IgfsMetaManager(cfg0.isRelaxedConsistency(), metaClient), new IgfsDataManager(), new IgfsServerManager(), new IgfsFragmentizerManager());
// Start managers first.
for (IgfsManager mgr : igfsCtx.managers()) mgr.start(igfsCtx);
igfsCache.put(cfg0.getName(), igfsCtx);
}
if (log.isDebugEnabled())
log.debug("IGFS processor started.");
// doesn't have configured caches.
if (igniteCfg.isDaemon() || F.isEmpty(igniteCfg.getFileSystemConfiguration()) || F.isEmpty(igniteCfg.getCacheConfiguration()))
return;
final Map<String, CacheConfiguration> cacheCfgs = new HashMap<>();
assert igniteCfg.getCacheConfiguration() != null;
for (CacheConfiguration ccfg : igniteCfg.getCacheConfiguration()) cacheCfgs.put(ccfg.getName(), ccfg);
Collection<IgfsAttributes> attrVals = new ArrayList<>();
assert igniteCfg.getFileSystemConfiguration() != null;
for (FileSystemConfiguration igfsCfg : igniteCfg.getFileSystemConfiguration()) {
String dataCacheName = igfsCfg.getDataCacheConfiguration().getName();
CacheConfiguration cacheCfg = cacheCfgs.get(dataCacheName);
if (cacheCfg == null)
// No cache for the given IGFS configuration.
continue;
AffinityKeyMapper affMapper = cacheCfg.getAffinityMapper();
if (!(affMapper instanceof IgfsGroupDataBlocksKeyMapper))
// Configuration will be validated later, while starting IgfsProcessor.
continue;
attrVals.add(new IgfsAttributes(igfsCfg.getName(), igfsCfg.getBlockSize(), ((IgfsGroupDataBlocksKeyMapper) affMapper).getGroupSize(), igfsCfg.getMetaCacheConfiguration().getName(), dataCacheName, igfsCfg.getDefaultMode(), igfsCfg.getPathModes(), igfsCfg.isFragmentizerEnabled()));
}
ctx.addNodeAttribute(ATTR_IGFS, attrVals.toArray(new IgfsAttributes[attrVals.size()]));
}
use of org.apache.ignite.configuration.IgniteConfiguration in project ignite by apache.
the class CacheExchangeMergeTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder);
if (testSpi)
cfg.setCommunicationSpi(new TestRecordingCommunicationSpi());
else if (testDelaySpi)
cfg.setCommunicationSpi(new TestDelayExchangeMessagesSpi());
Boolean clientMode = client.get();
if (clientMode == null && clientC != null)
clientMode = clientC.apply(igniteInstanceName);
if (clientMode != null) {
cfg.setClientMode(clientMode);
client.set(null);
}
if (cfgCache) {
cfg.setCacheConfiguration(cacheConfiguration("c1", ATOMIC, PARTITIONED, 0), cacheConfiguration("c2", ATOMIC, PARTITIONED, 1), cacheConfiguration("c3", ATOMIC, PARTITIONED, 2), cacheConfiguration("c4", ATOMIC, PARTITIONED, 10), cacheConfiguration("c5", ATOMIC, REPLICATED, 0), cacheConfiguration("c6", TRANSACTIONAL, PARTITIONED, 0), cacheConfiguration("c7", TRANSACTIONAL, PARTITIONED, 1), cacheConfiguration("c8", TRANSACTIONAL, PARTITIONED, 2), cacheConfiguration("c9", TRANSACTIONAL, PARTITIONED, 10), cacheConfiguration("c10", TRANSACTIONAL, REPLICATED, 0));
}
return cfg;
}
use of org.apache.ignite.configuration.IgniteConfiguration in project ignite by apache.
the class GridSingleExecutionTest method main.
/**
* @param args Command line arguments.
* @throws Exception If failed.
*/
@SuppressWarnings({ "CallToSystemExit" })
public static void main(String[] args) throws Exception {
System.setProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER, "false");
System.out.println("Starting master node [params=" + Arrays.toString(args) + ']');
if (args.length < 2) {
System.out.println("Log file name must be provided as first argument.");
System.exit(1);
} else if (args.length >= 2) {
for (IgniteConfiguration cfg : getConfigurations(args[1], args[0])) G.start(cfg);
}
boolean useSes = false;
if (args.length == 3) {
if ("-session".equals(args[2].trim()))
useSes = true;
}
try {
Ignite ignite = G.ignite();
// Execute Hello World task.
ComputeTaskFuture<Object> fut = ignite.compute().executeAsync(!useSes ? TestTask.class : TestSessionTask.class, null);
if (useSes) {
fut.getTaskSession().setAttribute("attr1", 1);
fut.getTaskSession().setAttribute("attr2", 2);
}
// Wait for task completion.
fut.get();
System.out.println("Task executed.");
} finally {
G.stop(true);
System.out.println("Master node stopped.");
}
}
Aggregations