use of org.apache.ignite.internal.GridKernalContext in project ignite by apache.
the class IgniteWalIteratorSwitchSegmentTest method checkInvariantSwitchSegmentSize.
/**
* @param serVer WAL serializer version.
* @throws Exception If some thing failed.
*/
private void checkInvariantSwitchSegmentSize(int serVer) throws Exception {
GridKernalContext kctx = new StandaloneGridKernalContext(log, null, null) {
@Override
public IgniteCacheObjectProcessor cacheObjects() {
return new CacheObjectBinaryProcessorImpl(this);
}
};
RecordSerializer serializer = new RecordSerializerFactoryImpl(new GridCacheSharedContext<>(kctx, null, null, null, null, null, null, new IgniteCacheDatabaseSharedManager() {
@Override
public int pageSize() {
return DataStorageConfiguration.DFLT_PAGE_SIZE;
}
}, null, null, null, null, null, null, null, null, null, null, null, null, null)).createSerializer(serVer);
SwitchSegmentRecord switchSegmentRecord = new SwitchSegmentRecord();
int recordSize = serializer.size(switchSegmentRecord);
Assert.assertEquals(1, recordSize);
}
use of org.apache.ignite.internal.GridKernalContext in project ignite by apache.
the class IgniteSecurityProcessorTest method testThrowIllegalStateExceptionIfNodeNotFoundInDiscoCache.
/**
* Checks that {@link IgniteSecurityProcessor#withContext(UUID)} throws exception in case a node ID is unknown.
*/
@Test
public void testThrowIllegalStateExceptionIfNodeNotFoundInDiscoCache() {
GridKernalContext ctx = mock(GridKernalContext.class);
when(ctx.config()).thenReturn(new IgniteConfiguration());
when(ctx.discovery()).thenReturn(mock(GridDiscoveryManager.class));
LogListener logLsnr = LogListener.matches(s -> s.contains("Failed to obtain a security context.")).times(1).build();
ListeningTestLogger log = new ListeningTestLogger(false);
log.registerListener(logLsnr);
when(ctx.log(IgniteSecurityProcessor.class)).thenReturn(log);
GridSecurityProcessor secPrc = mock(GridSecurityProcessor.class);
IgniteSecurityProcessor ignSecPrc = new IgniteSecurityProcessor(ctx, secPrc);
assertThrowsWithCause(() -> ignSecPrc.withContext(UUID.randomUUID()), IllegalStateException.class);
assertTrue(logLsnr.check());
}
use of org.apache.ignite.internal.GridKernalContext in project ignite by apache.
the class SqlViewExporterSpi method onContextInitialized0.
/**
* {@inheritDoc}
*/
@Override
protected void onContextInitialized0(IgniteSpiContext spiCtx) throws IgniteSpiException {
GridKernalContext ctx = ((IgniteEx) ignite()).context();
if (ctx.query().getIndexing() instanceof IgniteH2Indexing) {
mgr = ((IgniteH2Indexing) ctx.query().getIndexing()).schemaManager();
sysViewReg.forEach(this::register);
sysViewReg.addSystemViewCreationListener(this::register);
}
}
use of org.apache.ignite.internal.GridKernalContext in project ignite by apache.
the class RestProcessorAuthorizationTest method getPluginProvider.
/**
* {@inheritDoc}
*/
@Override
protected PluginProvider<?> getPluginProvider(String name) {
return new TestSecurityPluginProvider(name, null, ALLOW_ALL, globalAuth, clientData()) {
/**
* {@inheritDoc}
*/
@Override
protected GridSecurityProcessor securityProcessor(GridKernalContext ctx) {
return new TestSecurityProcessor(ctx, new TestSecurityData(login, pwd, perms, new Permissions()), Arrays.asList(clientData), globalAuth) {
/**
* {@inheritDoc}
*/
@Override
public void authorize(String name, SecurityPermission perm, SecurityContext securityCtx) throws SecurityException {
authorizationCtxList.add(F.t(name, perm, securityCtx));
super.authorize(name, perm, securityCtx);
}
};
}
};
}
use of org.apache.ignite.internal.GridKernalContext in project ignite by apache.
the class SqlViewMetricExporterSpi method onContextInitialized0.
/**
* {@inheritDoc}
*/
@Override
protected void onContextInitialized0(IgniteSpiContext spiCtx) throws IgniteSpiException {
GridKernalContext ctx = ((IgniteEx) ignite()).context();
if (!(ctx.query().getIndexing() instanceof IgniteH2Indexing))
return;
SchemaManager mgr = ((IgniteH2Indexing) ctx.query().getIndexing()).schemaManager();
mgr.createSystemView(SCHEMA_SYS, new MetricRegistryLocalSystemView(ctx, mreg));
if (log.isDebugEnabled())
log.debug(SYS_VIEW_NAME + " SQL view for metrics created.");
}
Aggregations