org.elasticsearch.common.UUIDs Java Examples
The following examples show how to use
org.elasticsearch.common.UUIDs.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QueryTester.java From crate with Apache License 2.0 | 6 votes |
void indexValue(String column, Object value) throws IOException { DocumentMapper mapper = indexEnv.mapperService().documentMapperSafe(); InsertSourceGen sourceGen = InsertSourceGen.of( CoordinatorTxnCtx.systemTransactionContext(), sqlExecutor.functions(), table, table.concreteIndices()[0], GeneratedColumns.Validation.NONE, Collections.singletonList(table.getReference(ColumnIdent.fromPath(column))) ); BytesReference source = sourceGen.generateSourceAndCheckConstraintsAsBytesReference(new Object[]{value}); SourceToParse sourceToParse = new SourceToParse( table.concreteIndices()[0], UUIDs.randomBase64UUID(), source, XContentType.JSON ); ParsedDocument parsedDocument = mapper.parse(sourceToParse); indexEnv.writer().addDocuments(parsedDocument.docs()); }
Example #2
Source File: TransportShardDeleteActionTest.java From crate with Apache License 2.0 | 6 votes |
@Before public void prepare() throws Exception { indexUUID = UUIDs.randomBase64UUID(); IndicesService indicesService = mock(IndicesService.class); IndexService indexService = mock(IndexService.class); when(indicesService.indexServiceSafe(new Index(TABLE_IDENT.indexNameOrAlias(), indexUUID))).thenReturn(indexService); indexShard = mock(IndexShard.class); when(indexService.getShard(0)).thenReturn(indexShard); transportShardDeleteAction = new TransportShardDeleteAction( MockTransportService.createNewService( Settings.EMPTY, Version.CURRENT, THREAD_POOL, clusterService.getClusterSettings()), mock(IndexNameExpressionResolver.class), mock(ClusterService.class), indicesService, mock(ThreadPool.class), mock(ShardStateAction.class), mock(SchemaUpdateClient.class) ); }
Example #3
Source File: ShardDeleteRequestTest.java From crate with Apache License 2.0 | 6 votes |
@Test public void testStreaming() throws Exception { ShardId shardId = new ShardId("test", UUIDs.randomBase64UUID(), 1); UUID jobId = UUID.randomUUID(); ShardDeleteRequest request = new ShardDeleteRequest(shardId, jobId); request.add(123, new ShardDeleteRequest.Item("99")); request.add(5, new ShardDeleteRequest.Item("42")); BytesStreamOutput out = new BytesStreamOutput(); request.writeTo(out); StreamInput in = out.bytes().streamInput(); ShardDeleteRequest request2 = new ShardDeleteRequest(in); assertThat(request, equalTo(request2)); }
Example #4
Source File: LuceneOrderedDocCollectorTest.java From crate with Apache License 2.0 | 6 votes |
private LuceneOrderedDocCollector collector(IndexSearcher searcher, List<LuceneCollectorExpression<?>> columnReferences, Query query, @Nullable Float minScore, boolean doDocScores) { return new LuceneOrderedDocCollector( new ShardId("dummy", UUIDs.base64UUID(), 0), searcher, query, minScore, doDocScores, 2, RamAccounting.NO_ACCOUNTING, new CollectorContext(), f -> null, new Sort(SortField.FIELD_SCORE), columnReferences, columnReferences ); }
Example #5
Source File: OrderedLuceneBatchIteratorFactoryTest.java From crate with Apache License 2.0 | 6 votes |
private LuceneOrderedDocCollector createOrderedCollector(IndexSearcher searcher, int shardId) { CollectorContext collectorContext = new CollectorContext(); List<LuceneCollectorExpression<?>> expressions = Collections.singletonList( new OrderByCollectorExpression(reference, orderBy, o -> o)); return new LuceneOrderedDocCollector( new ShardId("dummy", UUIDs.randomBase64UUID(), shardId), searcher, new MatchAllDocsQuery(), null, false, 5, // batchSize < 10 to have at least one searchMore call. RamAccounting.NO_ACCOUNTING, collectorContext, f -> null, new Sort(new SortedNumericSortField(columnName, SortField.Type.LONG, reverseFlags[0])), expressions, expressions ); }
Example #6
Source File: SerializationTests.java From crate with Apache License 2.0 | 6 votes |
@Test public void testPutChunkReplicaRequestSerialization() throws Exception { UUID transferId = UUID.randomUUID(); PutChunkReplicaRequest requestOut = new PutChunkReplicaRequest( new ShardId("foo", UUIDs.randomBase64UUID(), 1), "nodeId", transferId, 0, new BytesArray(new byte[]{0x65, 0x66}), false ); requestOut.index("foo"); BytesStreamOutput outputStream = new BytesStreamOutput(); requestOut.writeTo(outputStream); StreamInput inputStream = outputStream.bytes().streamInput(); PutChunkReplicaRequest requestIn = new PutChunkReplicaRequest(inputStream); assertEquals(requestOut.currentPos, requestIn.currentPos); assertEquals(requestOut.isLast, requestIn.isLast); assertEquals(requestOut.content, requestIn.content); assertEquals(requestOut.transferId, requestIn.transferId); assertEquals(requestOut.index(), requestIn.index()); }
Example #7
Source File: MockTransportService.java From crate with Apache License 2.0 | 6 votes |
/** * Build the service. * * @param clusterSettings if non null the {@linkplain TransportService} will register with the {@link ClusterSettings} for settings * updates for {@link TransportSettings#TRACE_LOG_EXCLUDE_SETTING} and {@link TransportSettings#TRACE_LOG_INCLUDE_SETTING}. */ public MockTransportService(Settings settings, Transport transport, ThreadPool threadPool, TransportInterceptor interceptor, @Nullable ClusterSettings clusterSettings) { this( settings, transport, threadPool, interceptor, (boundAddress) -> DiscoveryNode.createLocal( settings, boundAddress.publishAddress(), settings.get(Node.NODE_NAME_SETTING.getKey(), UUIDs.randomBase64UUID()) ), clusterSettings ); }
Example #8
Source File: MockTransportService.java From crate with Apache License 2.0 | 6 votes |
public static MockTransportService createNewService(Settings settings, Transport transport, Version version, ThreadPool threadPool, @Nullable ClusterSettings clusterSettings) { return new MockTransportService( settings, transport, threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR, boundAddress -> new DiscoveryNode( Node.NODE_NAME_SETTING.get(settings), UUIDs.randomBase64UUID(), boundAddress.publishAddress(), Node.NODE_ATTRIBUTES.getAsMap(settings), DiscoveryNode.getRolesFromSettings(settings), version ), clusterSettings ); }
Example #9
Source File: CoordinatorTests.java From crate with Apache License 2.0 | 6 votes |
void applyInitialConfiguration() { onNode(() -> { final Set<String> nodeIdsWithPlaceholders = new HashSet<>(initialConfiguration.getNodeIds()); Stream.generate(() -> BOOTSTRAP_PLACEHOLDER_PREFIX + UUIDs.randomBase64UUID(random())) .limit((Math.max(initialConfiguration.getNodeIds().size(), 2) - 1) / 2) .forEach(nodeIdsWithPlaceholders::add); final Set<String> nodeIds = new HashSet<>( randomSubsetOf(initialConfiguration.getNodeIds().size(), nodeIdsWithPlaceholders)); // initial configuration should not have a place holder for local node if (initialConfiguration.getNodeIds().contains(localNode.getId()) && nodeIds.contains(localNode.getId()) == false) { nodeIds.remove(nodeIds.iterator().next()); nodeIds.add(localNode.getId()); } final VotingConfiguration configurationWithPlaceholders = new VotingConfiguration(nodeIds); try { coordinator.setInitialConfiguration(configurationWithPlaceholders); logger.info("successfully set initial configuration to {}", configurationWithPlaceholders); } catch (CoordinationStateRejectedException e) { logger.info(new ParameterizedMessage("failed to set initial configuration to {}", configurationWithPlaceholders), e); } }).run(); }
Example #10
Source File: RepositoryDataTests.java From crate with Apache License 2.0 | 6 votes |
private static Map<IndexId, Set<SnapshotId>> randomIndices(final Map<String, SnapshotId> snapshotIdsMap) { final List<SnapshotId> snapshotIds = new ArrayList<>(snapshotIdsMap.values()); final int totalSnapshots = snapshotIds.size(); final int numIndices = randomIntBetween(1, 30); final Map<IndexId, Set<SnapshotId>> indices = new HashMap<>(numIndices); for (int i = 0; i < numIndices; i++) { final IndexId indexId = new IndexId(randomAlphaOfLength(8), UUIDs.randomBase64UUID()); final Set<SnapshotId> indexSnapshots = new LinkedHashSet<>(); final int numIndicesForSnapshot = randomIntBetween(1, numIndices); for (int j = 0; j < numIndicesForSnapshot; j++) { indexSnapshots.add(snapshotIds.get(randomIntBetween(0, totalSnapshots - 1))); } indices.put(indexId, indexSnapshots); } return indices; }
Example #11
Source File: RepositoryDataTests.java From crate with Apache License 2.0 | 6 votes |
public static RepositoryData generateRandomRepoData() { final int numIndices = randomIntBetween(1, 30); final List<IndexId> indices = new ArrayList<>(numIndices); for (int i = 0; i < numIndices; i++) { indices.add(new IndexId(randomAlphaOfLength(8), UUIDs.randomBase64UUID())); } final int numSnapshots = randomIntBetween(1, 30); RepositoryData repositoryData = RepositoryData.EMPTY; for (int i = 0; i < numSnapshots; i++) { final SnapshotId snapshotId = new SnapshotId(randomAlphaOfLength(8), UUIDs.randomBase64UUID()); final List<IndexId> someIndices = indices.subList(0, randomIntBetween(1, numIndices)); final ShardGenerations.Builder builder = ShardGenerations.builder(); for (IndexId someIndex : someIndices) { final int shardCount = randomIntBetween(1, 10); for (int j = 0; j < shardCount; ++j) { builder.put(someIndex, 0, UUIDs.randomBase64UUID(random())); } } repositoryData = repositoryData.addSnapshot(snapshotId, randomFrom(SnapshotState.values()), builder.build()); } return repositoryData; }
Example #12
Source File: RepositoryDataTests.java From crate with Apache License 2.0 | 6 votes |
public void testInitIndices() { final int numSnapshots = randomIntBetween(1, 30); final Map<String, SnapshotId> snapshotIds = new HashMap<>(numSnapshots); final Map<String, SnapshotState> snapshotStates = new HashMap<>(numSnapshots); for (int i = 0; i < numSnapshots; i++) { final SnapshotId snapshotId = new SnapshotId(randomAlphaOfLength(8), UUIDs.randomBase64UUID()); snapshotIds.put(snapshotId.getUUID(), snapshotId); snapshotStates.put(snapshotId.getUUID(), randomFrom(SnapshotState.values())); } RepositoryData repositoryData = new RepositoryData(EMPTY_REPO_GEN, snapshotIds, Collections.emptyMap(), Collections.emptyMap(), ShardGenerations.EMPTY); // test that initializing indices works Map<IndexId, Set<SnapshotId>> indices = randomIndices(snapshotIds); RepositoryData newRepoData = new RepositoryData(repositoryData.getGenId(), snapshotIds, snapshotStates, indices, ShardGenerations.EMPTY); List<SnapshotId> expected = new ArrayList<>(repositoryData.getSnapshotIds()); Collections.sort(expected); List<SnapshotId> actual = new ArrayList<>(newRepoData.getSnapshotIds()); Collections.sort(actual); assertEquals(expected, actual); for (IndexId indexId : indices.keySet()) { assertEquals(indices.get(indexId), newRepoData.getSnapshots(indexId)); } }
Example #13
Source File: TransportCreatePartitionsAction.java From crate with Apache License 2.0 | 6 votes |
private Settings createIndexSettings(ClusterState currentState, List<IndexTemplateMetaData> templates) { Settings.Builder indexSettingsBuilder = Settings.builder(); // apply templates, here, in reverse order, since first ones are better matching for (int i = templates.size() - 1; i >= 0; i--) { indexSettingsBuilder.put(templates.get(i).settings()); } if (indexSettingsBuilder.get(IndexMetaData.SETTING_VERSION_CREATED) == null) { DiscoveryNodes nodes = currentState.nodes(); final Version createdVersion = Version.min(Version.CURRENT, nodes.getSmallestNonClientNodeVersion()); indexSettingsBuilder.put(IndexMetaData.SETTING_VERSION_CREATED, createdVersion); } if (indexSettingsBuilder.get(IndexMetaData.SETTING_CREATION_DATE) == null) { indexSettingsBuilder.put(IndexMetaData.SETTING_CREATION_DATE, new DateTime(DateTimeZone.UTC).getMillis()); } indexSettingsBuilder.put(IndexMetaData.SETTING_INDEX_UUID, UUIDs.randomBase64UUID()); return indexSettingsBuilder.build(); }
Example #14
Source File: DecommissionAllocationDeciderTest.java From crate with Apache License 2.0 | 6 votes |
@Before public void init() throws Exception { routingAllocation = mock(RoutingAllocation.class); when(routingAllocation.decision(any(Decision.class), anyString(), anyString())).then(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { return invocation.getArguments()[0]; } }); primaryShard = ShardRouting.newUnassigned( new ShardId("t", UUIDs.randomBase64UUID(), 0), true, RecoverySource.PeerRecoverySource.INSTANCE, new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, "dummy")); replicaShard = ShardRouting.newUnassigned( new ShardId("t", UUIDs.randomBase64UUID(), 0), false, RecoverySource.PeerRecoverySource.INSTANCE, new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, "dummy") ); n1 = new RoutingNode("n1", mock(DiscoveryNode.class)); n2 = new RoutingNode("n2", mock(DiscoveryNode.class)); }
Example #15
Source File: SysSnapshotsTest.java From crate with Apache License 2.0 | 6 votes |
@Test public void testUnavailableSnapshotsAreFilteredOut() { HashMap<String, SnapshotId> snapshots = new HashMap<>(); SnapshotId s1 = new SnapshotId("s1", UUIDs.randomBase64UUID()); SnapshotId s2 = new SnapshotId("s2", UUIDs.randomBase64UUID()); snapshots.put(s1.getUUID(), s1); snapshots.put(s2.getUUID(), s2); RepositoryData repositoryData = new RepositoryData( 1, snapshots, Collections.emptyMap(), Collections.emptyMap(), ShardGenerations.EMPTY); Repository r1 = mock(Repository.class); when(r1.getRepositoryData()).thenReturn(repositoryData); when(r1.getMetadata()).thenReturn(new RepositoryMetaData("repo1", "fs", Settings.EMPTY)); when(r1.getSnapshotInfo(eq(s1))).thenThrow(new SnapshotException("repo1", "s1", "Everything is wrong")); when(r1.getSnapshotInfo(eq(s2))).thenReturn(new SnapshotInfo(s2, Collections.emptyList(), SnapshotState.SUCCESS)); SysSnapshots sysSnapshots = new SysSnapshots(() -> Collections.singletonList(r1)); List<SysSnapshot> currentSnapshots = ImmutableList.copyOf(sysSnapshots.currentSnapshots()); assertThat( currentSnapshots.stream().map(SysSnapshot::name).collect(Collectors.toList()), containsInAnyOrder("s1", "s2") ); }
Example #16
Source File: ElasticsearchTransportFactory.java From database-transform-tool with Apache License 2.0 | 6 votes |
public String bulkUpsert(String index,String type,List<Object> jsons){ try { if(client==null){ init(); } BulkRequestBuilder bulkRequest = client.prepareBulk(); for (Object json : jsons) { JSONObject obj = JSON.parseObject(JSON.toJSONString(json)); String id = UUIDs.base64UUID(); if(obj.containsKey("id")){ id = obj.getString("id"); obj.remove("id"); bulkRequest.add(client.prepareUpdate(index, type, id).setDoc(obj.toJSONString(),XContentType.JSON)); }else{ bulkRequest.add(client.prepareIndex(index, type, id).setSource(obj.toJSONString(),XContentType.JSON)); } } BulkResponse result = bulkRequest.execute().get(); return result.toString(); }catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
Example #17
Source File: RecoveryTarget.java From crate with Apache License 2.0 | 6 votes |
/** * Creates a new recovery target object that represents a recovery to the provided shard. * * @param indexShard local shard where we want to recover to * @param sourceNode source node of the recovery where we recover from * @param listener called when recovery is completed/failed * @param ensureClusterStateVersionCallback callback to ensure that the current node is at least on a cluster state with the provided * version; necessary for primary relocation so that new primary knows about all other ongoing * replica recoveries when replicating documents (see {@link RecoverySourceHandler}) */ public RecoveryTarget(final IndexShard indexShard, final DiscoveryNode sourceNode, final PeerRecoveryTargetService.RecoveryListener listener, final LongConsumer ensureClusterStateVersionCallback) { super("recovery_status"); this.cancellableThreads = new CancellableThreads(); this.recoveryId = ID_GENERATOR.incrementAndGet(); this.listener = listener; this.logger = Loggers.getLogger(getClass(), indexShard.shardId()); this.indexShard = indexShard; this.sourceNode = sourceNode; this.shardId = indexShard.shardId(); this.tempFilePrefix = RECOVERY_PREFIX + UUIDs.randomBase64UUID() + "."; this.store = indexShard.store(); this.ensureClusterStateVersionCallback = ensureClusterStateVersionCallback; // make sure the store is not released until we are done. store.incRef(); indexShard.recoveryStats().incCurrentAsTarget(); }
Example #18
Source File: BlobStoreRepository.java From crate with Apache License 2.0 | 6 votes |
@Override public String startVerification() { try { if (isReadOnly()) { // It's readonly - so there is not much we can do here to verify it apart from reading the blob store metadata latestIndexBlobId(); return "read-only"; } else { String seed = UUIDs.randomBase64UUID(); byte[] testBytes = seed.getBytes(StandardCharsets.UTF_8); BlobContainer testContainer = blobStore().blobContainer(basePath().add(testBlobPrefix(seed))); String blobName = "master.dat"; BytesArray bytes = new BytesArray(testBytes); try (InputStream stream = bytes.streamInput()) { testContainer.writeBlobAtomic(blobName, stream, bytes.length(), true); } return seed; } } catch (IOException exp) { throw new RepositoryVerificationException(metadata.name(), "path " + basePath() + " is not accessible on master node", exp); } }
Example #19
Source File: SQLExecutor.java From crate with Apache License 2.0 | 6 votes |
private static IndexMetaData.Builder getIndexMetaData(String indexName, Settings settings, @Nullable Map<String, Object> mapping, Version smallestNodeVersion) throws IOException { Settings.Builder builder = Settings.builder() .put(settings) .put(SETTING_VERSION_CREATED, smallestNodeVersion) .put(SETTING_CREATION_DATE, Instant.now().toEpochMilli()) .put(SETTING_INDEX_UUID, UUIDs.randomBase64UUID()); Settings indexSettings = builder.build(); IndexMetaData.Builder metaBuilder = IndexMetaData.builder(indexName) .settings(indexSettings); if (mapping != null) { metaBuilder.putMapping(new MappingMetaData( Constants.DEFAULT_MAPPING_TYPE, mapping)); } return metaBuilder; }
Example #20
Source File: Store.java From crate with Apache License 2.0 | 6 votes |
/** * Marks this store as corrupted. This method writes a {@code corrupted_${uuid}} file containing the given exception * message. If a store contains a {@code corrupted_${uuid}} file {@link #isMarkedCorrupted()} will return <code>true</code>. */ public void markStoreCorrupted(IOException exception) throws IOException { ensureOpen(); if (!isMarkedCorrupted()) { String uuid = CORRUPTED + UUIDs.randomBase64UUID(); try (IndexOutput output = this.directory().createOutput(uuid, IOContext.DEFAULT)) { CodecUtil.writeHeader(output, CODEC, VERSION); BytesStreamOutput out = new BytesStreamOutput(); out.writeException(exception); BytesReference bytes = out.bytes(); output.writeVInt(bytes.length()); BytesRef ref = bytes.toBytesRef(); output.writeBytes(ref.bytes, ref.offset, ref.length); CodecUtil.writeFooter(output); } catch (IOException ex) { logger.warn("Can't mark store as corrupted", ex); } directory().sync(Collections.singleton(uuid)); } }
Example #21
Source File: TestHelpers.java From anomaly-detection with Apache License 2.0 | 6 votes |
public static ClusterState createIndexBlockedState(String indexName, Settings hackedSettings, String alias) { ClusterState blockedClusterState = null; IndexMetadata.Builder builder = IndexMetadata.builder(indexName); if (alias != null) { builder.putAlias(AliasMetadata.builder(alias)); } IndexMetadata indexMetaData = builder .settings( Settings .builder() .put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID()) .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) .put(hackedSettings) ) .build(); Metadata metaData = Metadata.builder().put(indexMetaData, false).build(); blockedClusterState = ClusterState .builder(new ClusterName("test cluster")) .metadata(metaData) .blocks(ClusterBlocks.builder().addBlocks(indexMetaData)) .build(); return blockedClusterState; }
Example #22
Source File: TransportShardUpsertActionTest.java From crate with Apache License 2.0 | 5 votes |
@Before public void prepare() throws Exception { Functions functions = getFunctions(); charactersIndexUUID = UUIDs.randomBase64UUID(); partitionIndexUUID = UUIDs.randomBase64UUID(); IndicesService indicesService = mock(IndicesService.class); IndexService indexService = mock(IndexService.class); Index charactersIndex = new Index(TABLE_IDENT.indexNameOrAlias(), charactersIndexUUID); Index partitionIndex = new Index(PARTITION_INDEX, partitionIndexUUID); when(indicesService.indexServiceSafe(charactersIndex)).thenReturn(indexService); when(indicesService.indexServiceSafe(partitionIndex)).thenReturn(indexService); indexShard = mock(IndexShard.class); when(indexService.getShard(0)).thenReturn(indexShard); // Avoid null pointer exceptions DocTableInfo tableInfo = mock(DocTableInfo.class); Schemas schemas = mock(Schemas.class); when(tableInfo.columns()).thenReturn(Collections.<Reference>emptyList()); when(schemas.getTableInfo(any(RelationName.class), eq(Operation.INSERT))).thenReturn(tableInfo); transportShardUpsertAction = new TestingTransportShardUpsertAction( mock(ThreadPool.class), clusterService, MockTransportService.createNewService(Settings.EMPTY, Version.ES_V_6_5_1, THREAD_POOL, clusterService.getClusterSettings()), mock(SchemaUpdateClient.class), mock(TasksService.class), indicesService, mock(ShardStateAction.class), functions, schemas, mock(IndexNameExpressionResolver.class) ); }
Example #23
Source File: ElasticIndexer.java From Stargraph with MIT License | 5 votes |
@Override protected void doIndex(Serializable data, KBId kbId) throws InterruptedException { if (bulkProcessor == null) { throw new StarGraphException("Back-end is unreachable now."); } try { final String id = UUIDs.base64UUID(); IndexRequest request = esClient.createIndexRequest(id, true); this.indexRequests.put(id, request); bulkProcessor.add(request.source(mapper.writeValueAsBytes(data))); } catch (JsonProcessingException e) { throw new IndexingException(e); } }
Example #24
Source File: Store.java From crate with Apache License 2.0 | 5 votes |
/** * Marks an existing lucene index with a new history uuid and sets the given maxSeqNo as the local checkpoint * as well as the maximum sequence number. * This is used to make sure no existing shard will recover from this index using ops based recovery. * @see SequenceNumbers#LOCAL_CHECKPOINT_KEY * @see SequenceNumbers#MAX_SEQ_NO */ public void bootstrapNewHistory(long maxSeqNo) throws IOException { metadataLock.writeLock().lock(); try (IndexWriter writer = newIndexWriter(IndexWriterConfig.OpenMode.APPEND, directory, null)) { final Map<String, String> userData = getUserData(writer); final Map<String, String> map = new HashMap<>(); map.put(Engine.HISTORY_UUID_KEY, UUIDs.randomBase64UUID()); map.put(SequenceNumbers.MAX_SEQ_NO, Long.toString(maxSeqNo)); map.put(SequenceNumbers.LOCAL_CHECKPOINT_KEY, Long.toString(maxSeqNo)); logger.debug("bootstrap a new history_uuid [{}], user_data [{}]", map, userData); updateCommitData(writer, map); } finally { metadataLock.writeLock().unlock(); } }
Example #25
Source File: BlobIndicesServiceTest.java From crate with Apache License 2.0 | 5 votes |
@Test public void testBlobComponentsAreNotCreatedForNonBlobIndex() throws Exception { IndexService indexService = mock(IndexService.class); Index index = new Index("dummy", UUIDs.randomBase64UUID()); when(indexService.index()).thenReturn(index); blobIndicesService.afterIndexCreated(indexService); IndexShard indexShard = mock(IndexShard.class); when(indexShard.shardId()).thenReturn(new ShardId(index, 0)); blobIndicesService.afterIndexShardCreated(indexShard); assertThat(blobIndicesService.indices.keySet(), Matchers.empty()); }
Example #26
Source File: TestShardRouting.java From crate with Apache License 2.0 | 5 votes |
public static RecoverySource randomRecoverySource() { return ESTestCase.randomFrom(RecoverySource.EmptyStoreRecoverySource.INSTANCE, RecoverySource.ExistingStoreRecoverySource.INSTANCE, RecoverySource.PeerRecoverySource.INSTANCE, RecoverySource.LocalShardsRecoverySource.INSTANCE, new RecoverySource.SnapshotRecoverySource( new Snapshot("repo", new SnapshotId(randomAlphaOfLength(8), UUIDs.randomBase64UUID())), Version.CURRENT, "some_index")); }
Example #27
Source File: CoordinationStateTests.java From crate with Apache License 2.0 | 5 votes |
public static ClusterState clusterState(long term, long version, DiscoveryNodes discoveryNodes, VotingConfiguration lastCommittedConfig, VotingConfiguration lastAcceptedConfig, long value) { return setValue(ClusterState.builder(ClusterName.DEFAULT) .version(version) .nodes(discoveryNodes) .metaData(MetaData.builder() .clusterUUID(UUIDs.randomBase64UUID(random())) // generate cluster UUID deterministically for repeatable tests .coordinationMetaData(CoordinationMetaData.builder() .term(term) .lastCommittedConfiguration(lastCommittedConfig) .lastAcceptedConfiguration(lastAcceptedConfig) .build())) .stateUUID(UUIDs.randomBase64UUID(random())) // generate cluster state UUID deterministically for repeatable tests .build(), value); }
Example #28
Source File: CoordinationStateTests.java From crate with Apache License 2.0 | 5 votes |
public static DiscoveryNode createNode(String id) { final TransportAddress address = buildNewFakeTransportAddress(); return new DiscoveryNode("", id, UUIDs.randomBase64UUID(random()), // generated deterministically for repeatable tests address.address().getHostString(), address.getAddress(), address, Collections.emptyMap(), EnumSet.allOf(Role.class), Version.CURRENT); }
Example #29
Source File: CoordinatorTests.java From crate with Apache License 2.0 | 5 votes |
private static DiscoveryNode createDiscoveryNode(int nodeIndex, boolean masterEligible) { final TransportAddress address = buildNewFakeTransportAddress(); return new DiscoveryNode("", "node" + nodeIndex, UUIDs.randomBase64UUID(random()), // generated deterministically for repeatable tests address.address().getHostString(), address.getAddress(), address, Collections.emptyMap(), masterEligible ? EnumSet.allOf(Role.class) : emptySet(), Version.CURRENT); }
Example #30
Source File: RepositoryData.java From crate with Apache License 2.0 | 5 votes |
/** * Resolve the given index names to index ids, creating new index ids for * new indices in the repository. */ public List<IndexId> resolveNewIndices(final List<String> indicesToResolve) { List<IndexId> snapshotIndices = new ArrayList<>(); for (String index : indicesToResolve) { final IndexId indexId; if (indices.containsKey(index)) { indexId = indices.get(index); } else { indexId = new IndexId(index, UUIDs.randomBase64UUID()); } snapshotIndices.add(indexId); } return snapshotIndices; }