-
-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change how ZomboDB tracks and resolves visibility information to drastically improve performance over all previous versions.
- Loading branch information
1 parent
13568b8
commit 9cf4dce
Showing
62 changed files
with
1,777 additions
and
849 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
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
54 changes: 54 additions & 0 deletions
54
elasticsearch/src/main/java/com/tcdi/zombodb/postgres/RoutingHelper.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,54 @@ | ||
/* | ||
* Copyright 2017 ZomboDB, LLC | ||
* | ||
* 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. | ||
*/ | ||
package com.tcdi.zombodb.postgres; | ||
|
||
import org.elasticsearch.client.Client; | ||
import org.elasticsearch.cluster.ClusterService; | ||
import org.elasticsearch.cluster.ClusterState; | ||
import org.elasticsearch.cluster.routing.operation.OperationRouting; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
public class RoutingHelper { | ||
private static Map<String, String[]> ROUTING_TABLE = new ConcurrentHashMap<>(); | ||
|
||
public static String[] getRoutingTable(Client client, ClusterService clusterService, String index, int shards) { | ||
String key = index+"."+shards; | ||
|
||
String[] routingTable = ROUTING_TABLE.get(key); | ||
|
||
if (routingTable != null) | ||
return routingTable; | ||
|
||
ClusterState clusterState = clusterService.state(); | ||
OperationRouting operationRouting = clusterService.operationRouting(); | ||
|
||
routingTable = new String[shards]; | ||
for (int i=0; i<shards; i++) { | ||
String routing = String.valueOf(i); | ||
|
||
int cnt=0; | ||
while ( (operationRouting.indexShards(clusterState, index, "aborted", routing, null).shardId()).id() != i) | ||
routing = String.valueOf(i + ++cnt); | ||
routingTable[i] = routing; | ||
} | ||
|
||
ROUTING_TABLE.put(key, routingTable); | ||
return routingTable; | ||
|
||
} | ||
} |
Oops, something went wrong.