summaryrefslogtreecommitdiffstats
path: root/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/ContentPolicy.java
blob: d6e20b9d57f61883b3de170269909e22ce26e9ae (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
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.documentapi.messagebus.protocol;

import java.util.Map;

/**
 * Policy to talk to content clusters.
 */
public class ContentPolicy extends StoragePolicy {

    public static class ContentParameters extends Parameters {

        public ContentParameters(Map<String, String> parameters) {
            super(parameters);
        }

        @Override
        public String getDistributionConfigId() {
            if (distributionConfigId != null) {
                return distributionConfigId;
            }
            return clusterName;
        }

        @Override
        public SlobrokHostPatternGenerator createPatternGenerator() {
            return new SlobrokHostPatternGenerator(getClusterName()) {
                public String getDistributorHostPattern(Integer distributor) {
                    return "storage/cluster." + getClusterName() + "/distributor/" + (distributor == null ? "*" : distributor) + "/default";
                }
            };
        }
    }

    public ContentPolicy(Map<String, String> params) {
        super(new ContentParameters(params));
    }

    public ContentPolicy(String parameters) {
        this(parse(parameters));
    }

}