-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove synchronization of getters and default to async prestosql clus…
…ter manager
- Loading branch information
James Taylor
committed
Nov 5, 2020
1 parent
bb22e73
commit 9e0b728
Showing
9 changed files
with
170 additions
and
56 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
rubix-prestosql/src/main/java/com/qubole/rubix/prestosql/ClusterManagerNodeGetter.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 @@ | ||
/** | ||
* Copyright (c) 2019. Qubole Inc | ||
* Licensed 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. See accompanying LICENSE file. | ||
*/ | ||
package com.qubole.rubix.prestosql; | ||
|
||
import io.prestosql.spi.Node; | ||
import io.prestosql.spi.NodeManager; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
public class ClusterManagerNodeGetter { | ||
public static Set<String> getNodesInternal(NodeManager nodeManager) | ||
{ | ||
requireNonNull(nodeManager, "nodeManager is null"); | ||
return nodeManager.getWorkerNodes().stream() | ||
.map(Node::getHost) | ||
.collect(Collectors.toSet()); | ||
} | ||
} |
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
51 changes: 51 additions & 0 deletions
51
rubix-prestosql/src/main/java/com/qubole/rubix/prestosql/SyncPrestoClusterManager.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 @@ | ||
/** | ||
* Copyright (c) 2019. Qubole Inc | ||
* Licensed 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. See accompanying LICENSE file. | ||
*/ | ||
package com.qubole.rubix.prestosql; | ||
|
||
import com.qubole.rubix.spi.ClusterType; | ||
import com.qubole.rubix.spi.SyncClusterManager; | ||
import io.prestosql.spi.Node; | ||
import io.prestosql.spi.NodeManager; | ||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
|
||
import java.util.Set; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
public class SyncPrestoClusterManager extends SyncClusterManager | ||
{ | ||
private static Log log = LogFactory.getLog(SyncPrestoClusterManager.class); | ||
private volatile Set<Node> workerNodes; | ||
|
||
@Override | ||
protected boolean hasStateChanged() { | ||
requireNonNull(PrestoClusterManager.NODE_MANAGER, "nodeManager is null"); | ||
Set<Node> workerNodes = PrestoClusterManager.NODE_MANAGER.getWorkerNodes(); | ||
boolean hasChanged = !workerNodes.equals(this.workerNodes); | ||
this.workerNodes = workerNodes; | ||
return hasChanged; | ||
} | ||
|
||
@Override | ||
public Set<String> getNodesInternal() | ||
{ | ||
return ClusterManagerNodeGetter.getNodesInternal(PrestoClusterManager.NODE_MANAGER); | ||
} | ||
|
||
@Override | ||
public ClusterType getClusterType() | ||
{ | ||
return ClusterType.PRESTOSQL_CLUSTER_MANAGER; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
rubix-prestosql/src/test/java/com/qubole/rubix/prestosql/TestAsyncClusterManager.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,23 @@ | ||
/** | ||
* Copyright (c) 2019. Qubole Inc | ||
* Licensed 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. See accompanying LICENSE file. | ||
*/ | ||
package com.qubole.rubix.prestosql; | ||
|
||
import com.qubole.rubix.spi.ClusterManager; | ||
import org.apache.hadoop.conf.Configuration; | ||
|
||
public class TestAsyncClusterManager extends TestClusterManager { | ||
@Override | ||
protected ClusterManager newPrestoClusterManager(Configuration configuration) { | ||
return new PrestoClusterManager(); | ||
} | ||
} |
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
24 changes: 24 additions & 0 deletions
24
rubix-prestosql/src/test/java/com/qubole/rubix/prestosql/TestSyncClusterManager.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,24 @@ | ||
/** | ||
* Copyright (c) 2019. Qubole Inc | ||
* Licensed 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. See accompanying LICENSE file. | ||
*/ | ||
package com.qubole.rubix.prestosql; | ||
|
||
import com.qubole.rubix.spi.ClusterManager; | ||
import org.apache.hadoop.conf.Configuration; | ||
|
||
public class TestSyncClusterManager extends TestClusterManager { | ||
@Override | ||
protected ClusterManager newPrestoClusterManager(Configuration conf) { | ||
PrestoClusterManager.setNodeManager(new StandaloneNodeManager(conf)); | ||
return new SyncPrestoClusterManager(); | ||
} | ||
} |
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