use of io.crate.metadata.shard.ShardReferenceResolver in project crate by crate.
the class SysShardsExpressionsTest method prepare.
@Before
public void prepare() throws Exception {
ClusterService clusterService = new NoopClusterService();
indexShard = mockIndexShard();
schemas = new Schemas(Settings.EMPTY, ImmutableMap.of("sys", new SysSchemaInfo(clusterService)), clusterService, new DocSchemaInfoFactory(new TestingDocTableInfoFactory(Collections.emptyMap())));
ShardReferenceResolver shardRefResolver = new ShardReferenceResolver(clusterService, schemas, indexShard);
resolver = new RecoveryShardReferenceResolver(shardRefResolver, indexShard);
}
use of io.crate.metadata.shard.ShardReferenceResolver in project crate by crate.
the class SysShardsExpressionsTest method prepare.
@Before
public void prepare() {
NodeContext nodeCtx = createNodeContext();
indexShard = mockIndexShard();
CrateSettings crateSettings = new CrateSettings(clusterService, clusterService.getSettings());
UserDefinedFunctionService udfService = new UserDefinedFunctionService(clusterService, nodeCtx);
schemas = new Schemas(Map.of("sys", new SysSchemaInfo(this.clusterService, crateSettings)), clusterService, new DocSchemaInfoFactory(new TestingDocTableInfoFactory(Collections.emptyMap()), (ident, state) -> null, nodeCtx, udfService));
resolver = new ShardReferenceResolver(schemas, new ShardRowContext(indexShard, clusterService));
sysShards = schemas.getTableInfo(SysShardsTableInfo.IDENT);
}
use of io.crate.metadata.shard.ShardReferenceResolver in project crate by crate.
the class SysShardsExpressionsTest method testShardSizeExpressionWhenIndexShardHasBeenClosed.
@Test
public void testShardSizeExpressionWhenIndexShardHasBeenClosed() {
IndexShard mock = mockIndexShard();
when(mock.storeStats()).thenThrow(new AlreadyClosedException("shard already closed"));
ShardReferenceResolver resolver = new ShardReferenceResolver(schemas, new ShardRowContext(mock, clusterService));
Reference refInfo = refInfo("sys.shards.size", DataTypes.LONG, RowGranularity.SHARD);
NestableInput<Long> shardSizeExpression = (NestableInput<Long>) resolver.getImplementation(refInfo);
assertThat(shardSizeExpression.value(), is(0L));
}
use of io.crate.metadata.shard.ShardReferenceResolver in project crate by crate.
the class SysShardsExpressionsTest method test_retention_lease_is_null_on_index_shard_closed_exception.
@Test
public void test_retention_lease_is_null_on_index_shard_closed_exception() throws Exception {
IndexShard mock = mockIndexShard();
var shardId = mock.shardId();
doThrow(new IndexShardClosedException(shardId)).when(mock).getRetentionLeaseStats();
ShardReferenceResolver resolver = new ShardReferenceResolver(schemas, new ShardRowContext(mock, clusterService));
Reference refInfo = refInfo("sys.shards.retention_leases", DataTypes.LONG, RowGranularity.SHARD, "version");
NestableInput<Long> input = (NestableInput<Long>) resolver.getImplementation(refInfo);
assertThat(input.value(), Matchers.nullValue());
}
Aggregations