forked from apache/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes the recovery not respect to the isolation group settings (apach…
…e#8961) --- *Motivation* When users configure to use ZkIsolatedBookieEnsemblePlacementPolicy, it is hard to configure AutoRecovery to respect to the isolation group settings. Because we don't store the isolation group information as part of ledger metadata, the framework doesn't have any information to use for choosing the bookies. *Modifications* - Change the ZkIsolatedBookieEnsemblePlacementPolicy to use the policy passed from the custom metadata
- Loading branch information
Showing
10 changed files
with
298 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...n/src/main/java/org/apache/pulsar/common/policies/data/EnsemblePlacementPolicyConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.pulsar.common.policies.data; | ||
|
||
import com.google.common.base.Objects; | ||
import org.apache.bookkeeper.common.util.JsonUtil; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
public class EnsemblePlacementPolicyConfig { | ||
public static final String ENSEMBLE_PLACEMENT_POLICY_CONFIG = "EnsemblePlacementPolicyConfig"; | ||
private final Class policyClass; | ||
private final Map<String, Object> properties; | ||
|
||
// Add a default constructor for decode data from bytes to construct this. | ||
private EnsemblePlacementPolicyConfig() { | ||
this.policyClass = null; | ||
this.properties = Collections.emptyMap(); | ||
} | ||
|
||
public EnsemblePlacementPolicyConfig(Class policyClass, Map<String, Object> properties) { | ||
super(); | ||
this.policyClass = policyClass; | ||
this.properties = properties; | ||
} | ||
|
||
public Class getPolicyClass() { | ||
return policyClass; | ||
} | ||
|
||
public Map<String, Object> getProperties() { | ||
return properties; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hashCode(policyClass != null ? policyClass.getName() : "", properties); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj instanceof EnsemblePlacementPolicyConfig) { | ||
EnsemblePlacementPolicyConfig other = (EnsemblePlacementPolicyConfig) obj; | ||
return Objects.equal(this.policyClass == null ? null : this.policyClass.getName(), | ||
other.policyClass == null ? null : other.policyClass.getName()) | ||
&& Objects.equal(this.properties, other.properties); | ||
} | ||
return false; | ||
} | ||
|
||
public byte[] encode() throws JsonUtil.ParseJsonException { | ||
return JsonUtil.toJson(this).getBytes(StandardCharsets.UTF_8); | ||
} | ||
|
||
public static EnsemblePlacementPolicyConfig decode(byte[] data) throws JsonUtil.ParseJsonException { | ||
return JsonUtil.fromJson(new String(data, StandardCharsets.UTF_8), EnsemblePlacementPolicyConfig.class); | ||
} | ||
} |
Oops, something went wrong.