-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
L Server endpoints config #153
Merged
Merged
Changes from 5 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
9510292
Specify CAS and AC configs on memory instance
0c26752
remove whitespace
werkt cb6604a
Exception cleanup for now-abstract methods
werkt d0522f3
Remove debug MISSING_INPUT description
werkt c48a715
Remove disabled DelegateCASMap inheritance
werkt d192242
Remove unused map methods
6cebf82
Move digestMap initialization out of constructor
93621d7
Remove unused async bsStub
af80fed
Add get test consistent with contains check
2dae44d
Removing redundant parameter name comments
662370d
Add test to demonstrate NOT_FOUND get null return
1357792
Merge branch 'master' into server-endpoints-config
werkt 02ae8ec
Merge branch 'master' into server-endpoints-config
werkt 52134cf
Simplify OperationsMap interface and correct merge
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2018 The Bazel Authors. All rights reserved. | ||
// | ||
// 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 build.buildfarm.ac; | ||
|
||
import build.buildfarm.common.DigestUtil.ActionKey; | ||
import com.google.devtools.remoteexecution.v1test.ActionResult; | ||
|
||
public interface ActionCache { | ||
ActionResult get(ActionKey actionKey); | ||
|
||
void put(ActionKey actionKey, ActionResult actionResult) throws InterruptedException; | ||
} |
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,61 @@ | ||
// Copyright 2018 The Bazel Authors. All rights reserved. | ||
// | ||
// 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 build.buildfarm.ac; | ||
|
||
import build.buildfarm.common.DigestUtil.ActionKey; | ||
import com.google.common.base.Supplier; | ||
import com.google.common.base.Suppliers; | ||
import com.google.devtools.remoteexecution.v1test.ActionResult; | ||
import com.google.devtools.remoteexecution.v1test.ActionCacheGrpc; | ||
import com.google.devtools.remoteexecution.v1test.ActionCacheGrpc.ActionCacheBlockingStub; | ||
import com.google.devtools.remoteexecution.v1test.GetActionResultRequest; | ||
import com.google.devtools.remoteexecution.v1test.UpdateActionResultRequest; | ||
import io.grpc.Channel; | ||
|
||
public class GrpcActionCache implements ActionCache { | ||
private final String instanceName; | ||
private final Channel channel; | ||
|
||
public GrpcActionCache(String instanceName, Channel channel) { | ||
this.instanceName = instanceName; | ||
this.channel = channel; | ||
} | ||
|
||
private final Supplier<ActionCacheBlockingStub> actionCacheBlockingStub = | ||
Suppliers.memoize( | ||
new Supplier<ActionCacheBlockingStub>() { | ||
@Override | ||
public ActionCacheBlockingStub get() { | ||
return ActionCacheGrpc.newBlockingStub(channel); | ||
} | ||
}); | ||
|
||
@Override | ||
public ActionResult get(ActionKey actionKey) { | ||
return actionCacheBlockingStub.get().getActionResult(GetActionResultRequest.newBuilder() | ||
.setInstanceName(instanceName) | ||
.setActionDigest(actionKey.getDigest()) | ||
.build()); | ||
} | ||
|
||
@Override | ||
public void put(ActionKey actionKey, ActionResult actionResult) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm guessing retries for all these methods are coming later? Because now only the upload has them, IIUC. |
||
actionCacheBlockingStub.get().updateActionResult(UpdateActionResultRequest.newBuilder() | ||
.setInstanceName(instanceName) | ||
.setActionDigest(actionKey.getDigest()) | ||
.setActionResult(actionResult) | ||
.build()); | ||
} | ||
} |
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
52 changes: 52 additions & 0 deletions
52
src/main/java/build/buildfarm/cas/ContentAddressableStorages.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,52 @@ | ||
// Copyright 2018 The Bazel Authors. All rights reserved. | ||
// | ||
// 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 build.buildfarm.cas; | ||
|
||
import build.buildfarm.instance.stub.ByteStreamUploader; | ||
import build.buildfarm.instance.stub.Retrier; | ||
import build.buildfarm.v1test.ContentAddressableStorageConfig; | ||
import build.buildfarm.v1test.GrpcCASConfig; | ||
import io.grpc.Channel; | ||
import io.grpc.netty.NegotiationType; | ||
import io.grpc.netty.NettyChannelBuilder; | ||
|
||
public final class ContentAddressableStorages { | ||
private static Channel createChannel(String target) { | ||
NettyChannelBuilder builder = | ||
NettyChannelBuilder.forTarget(target) | ||
.negotiationType(NegotiationType.PLAINTEXT); | ||
return builder.build(); | ||
} | ||
|
||
private static ContentAddressableStorage createGrpcCAS(GrpcCASConfig config) { | ||
Channel channel = createChannel(config.getTarget()); | ||
ByteStreamUploader byteStreamUploader | ||
= new ByteStreamUploader("", channel, null, 300, Retrier.NO_RETRIES, null); | ||
|
||
return new GrpcCAS(config.getInstanceName(), channel, byteStreamUploader); | ||
} | ||
|
||
public static ContentAddressableStorage create(ContentAddressableStorageConfig config) { | ||
switch (config.getTypeCase()) { | ||
default: | ||
case TYPE_NOT_SET: | ||
throw new IllegalArgumentException("CAS config not set in config"); | ||
case GRPC: | ||
return createGrpcCAS(config.getGrpc()); | ||
case MEMORY: | ||
return new MemoryCAS(config.getMemory().getMaxSizeBytes()); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you need to transform NOT_FOUND status into null here?