Java Code Examples for org.elasticsearch.common.Strings#randomBase64UUID()

The following examples show how to use org.elasticsearch.common.Strings#randomBase64UUID() . 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: BlobStoreRepository.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public String startVerification() {
    try {
        if (readOnly()) {
            // It's readonly - so there is not much we can do here to verify it
            return null;
        } else {
            String seed = Strings.randomBase64UUID();
            byte[] testBytes = Strings.toUTF8Bytes(seed);
            BlobContainer testContainer = blobStore().blobContainer(basePath().add(testBlobPrefix(seed)));
            String blobName = "master.dat";
            testContainer.writeBlob(blobName + "-temp", new BytesArray(testBytes));
            // Make sure that move is supported
            testContainer.move(blobName + "-temp", blobName);
            return seed;
        }
    } catch (IOException exp) {
        throw new RepositoryVerificationException(repositoryName, "path " + basePath() + " is not accessible on master node", exp);
    }
}
 
Example 2
Source File: Store.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
/**
 * Marks this store as corrupted. This method writes a <tt>corrupted_${uuid}</tt> file containing the given exception
 * message. If a store contains a <tt>corrupted_${uuid}</tt> file {@link #isMarkedCorrupted()} will return <code>true</code>.
 */
public void markStoreCorrupted(IOException exception) throws IOException {
    ensureOpen();
    if (!isMarkedCorrupted()) {
        String uuid = CORRUPTED + Strings.randomBase64UUID();
        try (IndexOutput output = this.directory().createOutput(uuid, IOContext.DEFAULT)) {
            CodecUtil.writeHeader(output, CODEC, VERSION);
            BytesStreamOutput out = new BytesStreamOutput();
            out.writeThrowable(exception);
            BytesReference bytes = out.bytes();
            output.writeVInt(bytes.length());
            output.writeBytes(bytes.array(), bytes.arrayOffset(), bytes.length());
            CodecUtil.writeFooter(output);
        } catch (IOException ex) {
            logger.warn("Can't mark store as corrupted", ex);
        }
        directory().sync(Collections.singleton(uuid));
    }
}
 
Example 3
Source File: DiscoveryService.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public static String generateNodeId(Settings settings) {
    String seed = settings.get(DiscoveryService.SETTING_DISCOVERY_SEED);
    if (seed != null) {
        return Strings.randomBase64UUID(new Random(Long.parseLong(seed)));
    }
    return Strings.randomBase64UUID();
}
 
Example 4
Source File: ClusterState.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public ClusterState build() {
    if (UNKNOWN_UUID.equals(uuid)) {
        uuid = Strings.randomBase64UUID();
    }
    // if local node is the master node, then should not using any settings from any tenants
    if (!nodes.localNodeMaster()) {
        metaData.updateSettingsByNode(nodes.localNode());
    }
    ClusterState newState = new ClusterState(clusterName, version, uuid, metaData, routingTable, nodes, blocks, customs.build(), fromDiff);
    return newState;
}
 
Example 5
Source File: AllocationId.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new allocation id for initializing allocation.
 */
public static AllocationId newInitializing() {
    return new AllocationId(Strings.randomBase64UUID(), null);
}
 
Example 6
Source File: MetaData.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public Builder generateClusterUuidIfNeeded() {
    if (clusterUUID.equals("_na_")) {
        clusterUUID = Strings.randomBase64UUID();
    }
    return this;
}
 
Example 7
Source File: EsTypeImpl.java    From io with Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("rawtypes")
public DcIndexResponse create(final Map data) {
    String id = Strings.randomBase64UUID();
    return this.create(id, data);
}
 
Example 8
Source File: EsTypeImpl.java    From io with Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("rawtypes")
public DcIndexResponse create(final Map data) {
    String id = Strings.randomBase64UUID();
    return this.create(id, data);
}
 
Example 9
Source File: DcESUUID.java    From io with Apache License 2.0 2 votes vote down vote up
/**
 * ランダムなUUIDを返す.
 * @return UUID
 */
public static String randomUUID() {
    return Strings.randomBase64UUID();
}
 
Example 10
Source File: DcESUUID.java    From io with Apache License 2.0 2 votes vote down vote up
/**
 * ランダムなUUIDを返す.
 * @return UUID
 */
public static String randomUUID() {
    return Strings.randomBase64UUID();
}