Repository: incubator-blur Updated Branches: refs/heads/master 5a7d0f9de -> 1bbb14b2d
Thrift API change. Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/20b06bec Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/20b06bec Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/20b06bec Branch: refs/heads/master Commit: 20b06bec70d015da64c4a46896c1e83a68923391 Parents: 5a7d0f9 Author: Aaron McCurry <[email protected]> Authored: Fri Oct 31 10:34:14 2014 -0400 Committer: Aaron McCurry <[email protected]> Committed: Fri Oct 31 10:34:14 2014 -0400 ---------------------------------------------------------------------- .../apache/blur/command/ExecutionContext.java | 95 -------------------- .../org/apache/blur/command/ExecutionId.java | 61 ------------- .../src/main/scripts/interface/Blur.thrift | 12 +-- 3 files changed, 6 insertions(+), 162 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/20b06bec/blur-core/src/main/java/org/apache/blur/command/ExecutionContext.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/command/ExecutionContext.java b/blur-core/src/main/java/org/apache/blur/command/ExecutionContext.java deleted file mode 100644 index e5d783c..0000000 --- a/blur-core/src/main/java/org/apache/blur/command/ExecutionContext.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.blur.command; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; -import java.util.concurrent.Callable; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.Future; -import java.util.concurrent.atomic.AtomicBoolean; - -import org.apache.blur.log.Log; -import org.apache.blur.log.LogFactory; - -import com.google.common.collect.MapMaker; - -public class ExecutionContext { - - private static final Log LOG = LogFactory.getLog(ExecutionContext.class); - - private static ConcurrentMap<ExecutionId, ExecutionContext> _contextMap = new MapMaker().makeMap(); - private static ThreadLocal<ExecutionId> _currentId = new ThreadLocal<ExecutionId>(); - - public static ExecutionContext create() { - ExecutionId executionId = new ExecutionId(UUID.randomUUID().toString()); - ExecutionContext executionContext = new ExecutionContext(executionId); - _contextMap.put(executionId, executionContext); - _currentId.set(executionId); - return executionContext; - } - - public static ExecutionContext get() { - ExecutionId executionId = _currentId.get(); - return _contextMap.get(executionId); - } - - private final ExecutionId _executionId; - private final AtomicBoolean _running; - private final List<Future<?>> _futures = new ArrayList<Future<?>>(); - private Future<?> _driverFuture; - - public ExecutionContext(ExecutionId executionId) { - _executionId = executionId; - _running = new AtomicBoolean(true); - } - - public void registerFuture(Future<?> future) { - synchronized (_futures) { - _futures.add(future); - } - } - - public <T> Callable<T> wrapCallable(final Callable<T> callable) { - return new Callable<T>() { - @Override - public T call() throws Exception { - _currentId.set(_executionId); - LOG.info("Executing in new thread [{0}]", _executionId.getId()); - try { - return callable.call(); - } finally { - _currentId.set(null); - } - } - }; - } - - public ExecutionId getExecutionId() { - return _executionId; - } - - public AtomicBoolean getRunning() { - return _running; - } - - public <T> void registerDriverFuture(Future<T> driverFuture) { - _driverFuture = driverFuture; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/20b06bec/blur-core/src/main/java/org/apache/blur/command/ExecutionId.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/command/ExecutionId.java b/blur-core/src/main/java/org/apache/blur/command/ExecutionId.java deleted file mode 100644 index 496d9cc..0000000 --- a/blur-core/src/main/java/org/apache/blur/command/ExecutionId.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.blur.command; - -public class ExecutionId { - - private final String _id; - - public ExecutionId(String id) { - _id = id; - } - - public String getId() { - return _id; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((_id == null) ? 0 : _id.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ExecutionId other = (ExecutionId) obj; - if (_id == null) { - if (other._id != null) - return false; - } else if (!_id.equals(other._id)) - return false; - return true; - } - - @Override - public String toString() { - return "ExecutionId [_id=" + _id + "]"; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/20b06bec/distribution/src/main/scripts/interface/Blur.thrift ---------------------------------------------------------------------- diff --git a/distribution/src/main/scripts/interface/Blur.thrift b/distribution/src/main/scripts/interface/Blur.thrift index 60e757e..be1123c 100644 --- a/distribution/src/main/scripts/interface/Blur.thrift +++ b/distribution/src/main/scripts/interface/Blur.thrift @@ -60,7 +60,7 @@ exception BlurException { * happens so that the client can reconnect. */ exception TimeoutException { - 1:string executionId + 1:i64 instanceExecutionId } /** @@ -937,7 +937,7 @@ service Blur { * network tcp timeout this method allows the client to reconnect to the already * executing command. */ - Response reconnect(1:string executionId) throws (1:BlurException bex, 2:TimeoutException tex) + Response reconnect(1:i64 instanceExecutionId) throws (1:BlurException bex, 2:TimeoutException tex) /** * Fetches the command status ids in the order they were submitted. @@ -945,14 +945,14 @@ service Blur { list<string> commandStatusList(1:i32 startingAt, 2:i16 fetch, 3:CommandStatusState state) throws (1:BlurException ex) /** - * Retrieves the command status by the given execution id. + * Retrieves the command status by the given command execution id. */ - CommandStatus commandStatus(1:string executionId) throws (1:BlurException ex) + CommandStatus commandStatus(1:string commandExecutionId) throws (1:BlurException ex) /** - * Cancels the command with the given execution id. + * Cancels the command with the given command execution id. */ - void commandCancel(1:string executionId) throws (1:BlurException ex) + void commandCancel(1:string commandExecutionId) throws (1:BlurException ex) /** * Releases and refreshes the read snapshots of the indexes in the session for the
