mirror of https://github.com/apache/cassandra
rename getDefaultToken -> getInitialToken
patch by jbellis; reviewed by Jun Rao for CASSANDRA-65 git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@769019 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
296e15b63c
commit
bfb2e95220
|
|
@ -1113,7 +1113,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
|
|||
continue;
|
||||
}
|
||||
}
|
||||
if (Range.isTokenInRanges(StorageService.getPartitioner().getTokenForKey(lastkey), ranges))
|
||||
if (Range.isTokenInRanges(StorageService.getPartitioner().getInitialToken(lastkey), ranges))
|
||||
{
|
||||
if(ssTableRange == null )
|
||||
{
|
||||
|
|
@ -1143,7 +1143,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
|
|||
continue;
|
||||
}
|
||||
/* keep on looping until we find a key in the range */
|
||||
while (!Range.isTokenInRanges(StorageService.getPartitioner().getTokenForKey(filestruct.getKey()), ranges))
|
||||
while (!Range.isTokenInRanges(StorageService.getPartitioner().getInitialToken(filestruct.getKey()), ranges))
|
||||
{
|
||||
filestruct.advance();
|
||||
if (filestruct.isExhausted())
|
||||
|
|
|
|||
|
|
@ -37,7 +37,10 @@ public interface IPartitioner
|
|||
|
||||
public Comparator<String> getReverseDecoratedKeyComparator();
|
||||
|
||||
public Token getTokenForKey(String key);
|
||||
/**
|
||||
* @return the token to use for this node if none was saved
|
||||
*/
|
||||
public Token getInitialToken(String key);
|
||||
|
||||
public Token getDefaultToken();
|
||||
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ public class OrderPreservingPartitioner implements IPartitioner
|
|||
return tokenFactory;
|
||||
}
|
||||
|
||||
public Token getTokenForKey(String key)
|
||||
public Token getInitialToken(String key)
|
||||
{
|
||||
return new StringToken(key);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ public class RandomPartitioner implements IPartitioner
|
|||
return tokenFactory;
|
||||
}
|
||||
|
||||
public Token getTokenForKey(String key)
|
||||
public Token getInitialToken(String key)
|
||||
{
|
||||
return new BigIntegerToken(FBUtilities.hash(key));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ public class RackAwareStrategy extends AbstractStrategy
|
|||
|
||||
for ( String key : keys )
|
||||
{
|
||||
results.put(key, getStorageEndPoints(partitioner_.getTokenForKey(key)));
|
||||
results.put(key, getStorageEndPoints(partitioner_.getInitialToken(key)));
|
||||
}
|
||||
|
||||
return results;
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public class RackUnawareStrategy extends AbstractStrategy
|
|||
|
||||
for ( String key : keys )
|
||||
{
|
||||
results.put(key, getStorageEndPoints(partitioner_.getTokenForKey(key)));
|
||||
results.put(key, getStorageEndPoints(partitioner_.getInitialToken(key)));
|
||||
}
|
||||
|
||||
return results;
|
||||
|
|
|
|||
|
|
@ -774,7 +774,7 @@ public final class StorageService implements IEndPointStateChangeSubscriber, Sto
|
|||
Token[] tokens = tokenToEndPointMap.keySet().toArray(new Token[tokenToEndPointMap.keySet().size()]);
|
||||
Arrays.sort(tokens);
|
||||
int index = Arrays.binarySearch(tokens, token) * (keys.length/tokens.length);
|
||||
Token newToken = partitioner_.getTokenForKey(keys[index]);
|
||||
Token newToken = partitioner_.getInitialToken(keys[index]);
|
||||
/* update the token */
|
||||
updateToken(newToken);
|
||||
}
|
||||
|
|
@ -1064,7 +1064,7 @@ public final class StorageService implements IEndPointStateChangeSubscriber, Sto
|
|||
public EndPoint getPrimary(String key)
|
||||
{
|
||||
EndPoint endpoint = StorageService.tcpAddr_;
|
||||
Token token = partitioner_.getTokenForKey(key);
|
||||
Token token = partitioner_.getInitialToken(key);
|
||||
Map<Token, EndPoint> tokenToEndPointMap = tokenMetadata_.cloneTokenEndPointMap();
|
||||
List tokens = new ArrayList<Token>(tokenToEndPointMap.keySet());
|
||||
if (tokens.size() > 0)
|
||||
|
|
@ -1112,7 +1112,7 @@ public final class StorageService implements IEndPointStateChangeSubscriber, Sto
|
|||
*/
|
||||
public EndPoint[] getNStorageEndPoint(String key)
|
||||
{
|
||||
return nodePicker_.getStorageEndPoints(partitioner_.getTokenForKey(key));
|
||||
return nodePicker_.getStorageEndPoints(partitioner_.getInitialToken(key));
|
||||
}
|
||||
|
||||
private Map<String, EndPoint[]> getNStorageEndPoints(String[] keys)
|
||||
|
|
@ -1151,7 +1151,7 @@ public final class StorageService implements IEndPointStateChangeSubscriber, Sto
|
|||
*/
|
||||
public Map<EndPoint, EndPoint> getNStorageEndPointMap(String key)
|
||||
{
|
||||
return nodePicker_.getHintedStorageEndPoints(partitioner_.getTokenForKey(key));
|
||||
return nodePicker_.getHintedStorageEndPoints(partitioner_.getInitialToken(key));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package org.apache.cassandra.locator;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.math.BigInteger;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
import org.apache.cassandra.dht.IPartitioner;
|
||||
|
|
@ -42,7 +41,7 @@ public class RackUnawareStrategyTest
|
|||
List<Token> keyTokens = new ArrayList<Token>();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
endPointTokens.add(new StringToken(String.valueOf((char)('a' + i * 2))));
|
||||
keyTokens.add(partitioner.getTokenForKey(String.valueOf((char)('a' + i * 2 + 1))));
|
||||
keyTokens.add(partitioner.getInitialToken(String.valueOf((char)('a' + i * 2 + 1))));
|
||||
}
|
||||
testGetStorageEndPoints(tmd, strategy, endPointTokens.toArray(new Token[0]), keyTokens.toArray(new Token[0]));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,6 @@ import java.io.IOException;
|
|||
public class SystemTableTest extends ServerTest {
|
||||
@Test
|
||||
public void testMain() throws IOException {
|
||||
SystemTable.openSystemTable(SystemTable.cfName_).updateToken(StorageService.getPartitioner().getTokenForKey("503545744:0"));
|
||||
SystemTable.openSystemTable(SystemTable.cfName_).updateToken(StorageService.getPartitioner().getInitialToken("503545744:0"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue