forked from apache/incubator-uniffle
-
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.
[apache#1709] feat(coordinator): Introduce pluggable `ClientConfApply…
…Strategy` for `fetchClientConf` rpc (apache#1710) ### What changes were proposed in this pull request? Introduce pluggable ClientConfApplyManager for fetchClientConf rpc ### Why are the changes needed? For apache#1709 ### Does this PR introduce _any_ user-facing change? Yes. ### How was this patch tested? Unit tests
- Loading branch information
Showing
13 changed files
with
388 additions
and
13 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
30 changes: 30 additions & 0 deletions
30
...src/main/java/org/apache/uniffle/coordinator/conf/AbstractRssClientConfApplyStrategy.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,30 @@ | ||
/* | ||
* 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.uniffle.coordinator.conf; | ||
|
||
import java.util.Map; | ||
|
||
public abstract class AbstractRssClientConfApplyStrategy { | ||
protected DynamicClientConfService dynamicClientConfService; | ||
|
||
protected AbstractRssClientConfApplyStrategy(DynamicClientConfService dynamicClientConfService) { | ||
this.dynamicClientConfService = dynamicClientConfService; | ||
} | ||
|
||
abstract Map<String, String> apply(RssClientConfFetchInfo rssClientConfFetchInfo); | ||
} |
32 changes: 32 additions & 0 deletions
32
...r/src/main/java/org/apache/uniffle/coordinator/conf/BypassRssClientConfApplyStrategy.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,32 @@ | ||
/* | ||
* 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.uniffle.coordinator.conf; | ||
|
||
import java.util.Map; | ||
|
||
public class BypassRssClientConfApplyStrategy extends AbstractRssClientConfApplyStrategy { | ||
|
||
public BypassRssClientConfApplyStrategy(DynamicClientConfService dynamicClientConfService) { | ||
super(dynamicClientConfService); | ||
} | ||
|
||
@Override | ||
Map<String, String> apply(RssClientConfFetchInfo rssClientConfFetchInfo) { | ||
return dynamicClientConfService.getRssClientConf(); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
coordinator/src/main/java/org/apache/uniffle/coordinator/conf/RssClientConfApplyManager.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,62 @@ | ||
/* | ||
* 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.uniffle.coordinator.conf; | ||
|
||
import java.io.Closeable; | ||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
import com.google.common.annotations.VisibleForTesting; | ||
|
||
import org.apache.uniffle.common.util.RssUtils; | ||
import org.apache.uniffle.coordinator.CoordinatorConf; | ||
|
||
import static org.apache.uniffle.coordinator.CoordinatorConf.COORDINATOR_CLIENT_CONF_APPLY_STRATEGY; | ||
|
||
public class RssClientConfApplyManager implements Closeable { | ||
private final AbstractRssClientConfApplyStrategy strategy; | ||
private final DynamicClientConfService dynamicClientConfService; | ||
|
||
public RssClientConfApplyManager( | ||
CoordinatorConf conf, DynamicClientConfService dynamicClientConfService) { | ||
this.dynamicClientConfService = dynamicClientConfService; | ||
|
||
String strategyCls = conf.get(COORDINATOR_CLIENT_CONF_APPLY_STRATEGY); | ||
this.strategy = | ||
RssUtils.loadExtension( | ||
AbstractRssClientConfApplyStrategy.class, strategyCls, dynamicClientConfService); | ||
} | ||
|
||
public Map<String, String> apply(RssClientConfFetchInfo rssClientConfFetchInfo) { | ||
// to be compatible with the older client version. | ||
if (rssClientConfFetchInfo.isEmpty()) { | ||
return dynamicClientConfService.getRssClientConf(); | ||
} | ||
return strategy.apply(rssClientConfFetchInfo); | ||
} | ||
|
||
@VisibleForTesting | ||
protected AbstractRssClientConfApplyStrategy getStrategy() { | ||
return strategy; | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
// ignore. | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
coordinator/src/main/java/org/apache/uniffle/coordinator/conf/RssClientConfFetchInfo.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,51 @@ | ||
/* | ||
* 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.uniffle.coordinator.conf; | ||
|
||
import java.util.Map; | ||
|
||
import org.apache.uniffle.proto.RssProtos; | ||
|
||
public class RssClientConfFetchInfo { | ||
private String user; | ||
private Map<String, String> properties; | ||
|
||
public static final RssClientConfFetchInfo EMPTY_CLIENT_CONF_FETCH_INFO = | ||
new RssClientConfFetchInfo(null, null); | ||
|
||
public RssClientConfFetchInfo(String user, Map<String, String> properties) { | ||
this.user = user; | ||
this.properties = properties; | ||
} | ||
|
||
public String getUser() { | ||
return user; | ||
} | ||
|
||
public Map<String, String> getProperties() { | ||
return properties; | ||
} | ||
|
||
public boolean isEmpty() { | ||
return user == null && (properties == null || properties.isEmpty()); | ||
} | ||
|
||
public static RssClientConfFetchInfo fromProto(RssProtos.FetchClientConfRequest request) { | ||
return new RssClientConfFetchInfo(request.getUser(), request.getPropertiesMap()); | ||
} | ||
} |
Oops, something went wrong.