summaryrefslogtreecommitdiffstats
path: root/config-model-api/src/main/java/com/yahoo/config/application/api/FileRegistry.java
blob: 8f75d97d2d4a4f0d0cfa2a2da60dfee2d6c8ad1e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.application.api;

import java.nio.ByteBuffer;
import java.util.List;

import com.yahoo.config.FileReference;
import com.yahoo.net.HostName;
import net.jpountz.xxhash.XXHashFactory;


/**
 * @author Tony Vaagenes
 */
public interface FileRegistry {

    FileReference addFile(String relativePath);
    FileReference addUri(String uri);
    /**
     * @deprecated Remove after 7.455
     */
    @Deprecated
    default FileReference addBlob(ByteBuffer blob) { return null; }
    FileReference addBlob(String name, ByteBuffer blob);
    default FileReference addApplicationPackage() { return addFile(""); }

    /**
     * Returns the name of the host which is the source of the files
     * @deprecated Remove after 7.453
     */
    @Deprecated
    default String fileSourceHost() { return HostName.getLocalhost(); }

    List<Entry> export();

    class Entry {
        public final String relativePath;
        public final FileReference reference;

        public Entry(String relativePath, FileReference reference) {
            this.relativePath = relativePath;
            this.reference = reference;
        }
    }

    /**
     * @deprecated Remove after 7.455
     */
    @Deprecated
    static String blobName(ByteBuffer blob) {
        blob.mark();
        long blobHash = XXHashFactory.fastestJavaInstance().hash64().hash(blob, 0);
        blob.reset();
        return Long.toHexString(blobHash);
    }

}