本文整理了Java中com.vmware.xenon.common.Utils.computeHash()
方法的一些代码示例,展示了Utils.computeHash()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.computeHash()
方法的具体详情如下:
包路径:com.vmware.xenon.common.Utils
类名称:Utils
方法名:computeHash
暂无
代码示例来源:origin: com.vmware.photon.controller/photon-model
/**
* Override the buildDefaultChildSelfLink method to set the documentSelfLink.
*/
@Override
protected String buildDefaultChildSelfLink(ServiceDocument document) {
SessionState state = (SessionState) document;
return Utils.computeHash(state.localToken);
}
代码示例来源:origin: vmware/admiral
private String toHashedName(String name, int maxLen) {
name = name.toLowerCase();
if (name.length() <= maxLen) {
return name;
}
String hash = Utils.computeHash(name);
return name.substring(0, maxLen - 1 - hash.length()) + '_' + hash;
}
代码示例来源:origin: vmware/admiral
private String addSnapshotId(JsonObject obj, String type, String... values) {
StringJoiner s = new StringJoiner(",");
s.add(type);
Stream.of(values).forEach(s::add);
String snapshotId = Utils.computeHash(s.toString());
obj.addProperty("snapshotId", snapshotId);
// return id as type#snapshotId
return type + "#" + snapshotId;
}
代码示例来源:origin: vmware/xenon
this.state.id = args.id;
this.hashedId = Utils.computeHash(this.state.id);
代码示例来源:origin: com.vmware.photon.controller/photon-model
public static URI buildSessionURI(Service service, AuthorizationContext ctx) {
return createInventoryUri(service.getHost(), UriUtils.buildUriPath(FACTORY_LINK,
Utils.computeHash(ctx.getToken())));
}
代码示例来源:origin: com.vmware.photon.controller/photon-model
@Override
public void handleGet(Operation op) {
if (op.getAuthorizationContext() != null && op.getAuthorizationContext().isSystemUser()) {
super.handleGet(op);
return;
}
// Allows a user to access her own token map
if (op.getAuthorizationContext() != null &&
op.getAuthorizationContext().getToken() != null &&
op.getUri().getPath().endsWith(
FACTORY_LINK + "/" +
Utils.computeHash(op.getAuthorizationContext().getToken()))) {
super.handleGet(op);
return;
}
op.fail(Operation.STATUS_CODE_UNAUTHORIZED);
}
代码示例来源:origin: vmware/xenon
@Test
public void buildChildSelfLink() throws Throwable {
SomeFactoryService f = new SomeFactoryService();
f = (SomeFactoryService) this.host.startServiceAndWait(f,
UUID.randomUUID().toString(),
null);
// this test assumes how the implementation works. If we change
// the implementation, it will break, by design
String idHash = Utils.computeHash(this.host.getId());
assertTrue(f.buildDefaultChildSelfLink().startsWith(idHash));
long s = System.nanoTime();
for (int i = 0; i < this.iterationCount; i++) {
assertTrue(f.buildDefaultChildSelfLink() != null);
}
long e = System.nanoTime();
double thpt = (double) this.iterationCount / (e - s);
thpt *= TimeUnit.SECONDS.toNanos(1);
this.host.log("throughput (calls/sec) %f", thpt);
s = System.nanoTime();
for (int i = 0; i < this.iterationCount; i++) {
assertTrue(UUID.randomUUID().toString() != null);
}
e = System.nanoTime();
thpt = (double) this.iterationCount / (e - s);
thpt *= TimeUnit.SECONDS.toNanos(1);
this.host.log("UUID.randomUUID().toString() throughput (calls/sec) %f", thpt);
}
代码示例来源:origin: com.vmware.xenon/xenon-common
@Test
public void buildChildSelfLink() throws Throwable {
SomeFactoryService f = new SomeFactoryService();
f = (SomeFactoryService) this.host.startServiceAndWait(f,
UUID.randomUUID().toString(),
null);
// this test assumes how the implementation works. If we change
// the implementation, it will break, by design
String idHash = Utils.computeHash(this.host.getId());
assertTrue(f.buildDefaultChildSelfLink().startsWith(idHash));
long s = System.nanoTime();
for (int i = 0; i < this.iterationCount; i++) {
assertTrue(f.buildDefaultChildSelfLink() != null);
}
long e = System.nanoTime();
double thpt = (double) this.iterationCount / (e - s);
thpt *= TimeUnit.SECONDS.toNanos(1);
this.host.log("throughput (calls/sec) %f", thpt);
s = System.nanoTime();
for (int i = 0; i < this.iterationCount; i++) {
assertTrue(UUID.randomUUID().toString() != null);
}
e = System.nanoTime();
thpt = (double) this.iterationCount / (e - s);
thpt *= TimeUnit.SECONDS.toNanos(1);
this.host.log("UUID.randomUUID().toString() throughput (calls/sec) %f", thpt);
}
代码示例来源:origin: com.vmware.xenon/xenon-common
try {
Logger log = Logger.getAnonymousLogger();
String baseId = Utils.computeHash("some id");
代码示例来源:origin: vmware/xenon
try {
Logger log = Logger.getAnonymousLogger();
String baseId = Utils.computeHash("some id");
内容来源于网络,如有侵权,请联系作者删除!