Initial commit of generic command execution on new blur platform.
Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/486d37b5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/486d37b5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/486d37b5 Branch: refs/heads/blur-platform Commit: 486d37b52957385bc50005a395317617f8f6cd65 Parents: 33e2196 Author: Aaron McCurry <[email protected]> Authored: Thu Jul 24 10:06:35 2014 -0400 Committer: Aaron McCurry <[email protected]> Committed: Thu Jul 24 10:06:35 2014 -0400 ---------------------------------------------------------------------- blur-core/pom.xml | 5 + .../apache/blur/server/FilteredBlurServer.java | 7 + .../apache/blur/server/platform/Command.java | 93 + .../blur/server/platform/CommandClient.java | 87 + .../server/platform/CommandClientExample.java | 54 + .../blur/server/platform/CommandException.java | 23 + .../server/platform/CommandShardServer.java | 121 + .../blur/server/platform/CommandUtils.java | 95 + .../blur/server/platform/TableShardKey.java | 38 + .../blur/thrift/BlurControllerServer.java | 7 + .../org/apache/blur/thrift/BlurShardServer.java | 22 + .../generated/AdhocByteCodeCommandRequest.java | 886 ++ .../generated/AdhocByteCodeCommandResponse.java | 410 + .../org/apache/blur/thrift/generated/Blur.java | 766 +- .../thrift/generated/BlurCommandRequest.java | 409 + .../thrift/generated/BlurCommandResponse.java | 315 + .../blur/thrift/generated/BlurPlatform.java | 1019 ++ .../org/apache/blur/thrift/generated/Value.java | 532 + .../apache/blur/thrift/generated/ValueType.java | 82 + .../src/main/scripts/interface/Blur.thrift | 44 +- .../main/scripts/interface/gen-html/Blur.html | 54 +- .../main/scripts/interface/gen-html/index.html | 14 +- .../generated/AdhocByteCodeCommandRequest.java | 886 ++ .../generated/AdhocByteCodeCommandResponse.java | 410 + .../org/apache/blur/thrift/generated/Blur.java | 766 +- .../thrift/generated/BlurCommandRequest.java | 409 + .../thrift/generated/BlurCommandResponse.java | 315 + .../blur/thrift/generated/BlurPlatform.java | 1019 ++ .../org/apache/blur/thrift/generated/Value.java | 532 + .../apache/blur/thrift/generated/ValueType.java | 82 + .../src/main/scripts/interface/gen-js/Blur.js | 672 +- .../scripts/interface/gen-js/BlurPlatform.js | 178 + .../main/scripts/interface/gen-js/Blur_types.js | 448 + .../scripts/interface/gen-perl/Blur/Blur.pm | 13577 ++++++++--------- .../interface/gen-perl/Blur/BlurPlatform.pm | 302 + .../scripts/interface/gen-perl/Blur/Types.pm | 496 + .../src/main/scripts/interface/gen-rb/blur.rb | 5 +- .../scripts/interface/gen-rb/blur_platform.rb | 87 + .../main/scripts/interface/gen-rb/blur_types.rb | 124 + docs/Blur.html | 2 + pom.xml | 1 + 41 files changed, 17487 insertions(+), 7907 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/486d37b5/blur-core/pom.xml ---------------------------------------------------------------------- diff --git a/blur-core/pom.xml b/blur-core/pom.xml index 997dbf2..1359561 100644 --- a/blur-core/pom.xml +++ b/blur-core/pom.xml @@ -39,6 +39,11 @@ under the License. <dependencies> <dependency> + <groupId>janino</groupId> + <artifactId>janino</artifactId> + <version>${janino.version}</version> + </dependency> + <dependency> <groupId>org.apache.blur</groupId> <artifactId>blur-thrift</artifactId> <version>${project.version}</version> http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/486d37b5/blur-core/src/main/java/org/apache/blur/server/FilteredBlurServer.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/server/FilteredBlurServer.java b/blur-core/src/main/java/org/apache/blur/server/FilteredBlurServer.java index 53e59fe..89552d0 100644 --- a/blur-core/src/main/java/org/apache/blur/server/FilteredBlurServer.java +++ b/blur-core/src/main/java/org/apache/blur/server/FilteredBlurServer.java @@ -23,6 +23,8 @@ import java.util.Set; import org.apache.blur.BlurConfiguration; import org.apache.blur.thirdparty.thrift_0_9_0.TException; import org.apache.blur.thrift.generated.Blur.Iface; +import org.apache.blur.thrift.generated.BlurCommandRequest; +import org.apache.blur.thrift.generated.BlurCommandResponse; import org.apache.blur.thrift.generated.BlurException; import org.apache.blur.thrift.generated.BlurQuery; import org.apache.blur.thrift.generated.BlurQueryStatus; @@ -244,4 +246,9 @@ public class FilteredBlurServer implements Iface { _iface.enqueueMutateBatch(mutations); } + @Override + public BlurCommandResponse execute(BlurCommandRequest request) throws BlurException, TException { + return _iface.execute(request); + } + } http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/486d37b5/blur-core/src/main/java/org/apache/blur/server/platform/Command.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/server/platform/Command.java b/blur-core/src/main/java/org/apache/blur/server/platform/Command.java new file mode 100644 index 0000000..2d97e0e --- /dev/null +++ b/blur-core/src/main/java/org/apache/blur/server/platform/Command.java @@ -0,0 +1,93 @@ +/** + * 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.server.platform; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; + +import org.apache.blur.manager.writer.BlurIndex; + +public abstract class Command<T1, T2> { + + private ExecutorService _executorService; + private Object[] _args; + + public Object[] getArgs() { + return _args; + } + + public void setArgs(Object[] args) { + _args = args; + } + + public void setExecutorService(ExecutorService executorService) { + _executorService = executorService; + } + + public T2 process(Map<String, Map<String, BlurIndex>> indexes) throws CommandException, IOException { + List<Future<Map<TableShardKey, T1>>> futures = new ArrayList<Future<Map<TableShardKey, T1>>>(); + for (Entry<String, Map<String, BlurIndex>> tableEntry : indexes.entrySet()) { + String table = tableEntry.getKey(); + Map<String, BlurIndex> shards = tableEntry.getValue(); + for (Entry<String, BlurIndex> shardEntry : shards.entrySet()) { + String shard = shardEntry.getKey(); + final BlurIndex blurIndex = shardEntry.getValue(); + final TableShardKey tableShardKey = new TableShardKey(table, shard); + futures.add(_executorService.submit(new Callable<Map<TableShardKey, T1>>() { + @Override + public Map<TableShardKey, T1> call() throws Exception { + return processShard(tableShardKey, blurIndex); + } + })); + } + } + + CommandException commandException = new CommandException(); + boolean error = false; + Map<TableShardKey, T1> results = new HashMap<TableShardKey, T1>(); + for (Future<Map<TableShardKey, T1>> future : futures) { + try { + results.putAll(future.get()); + } catch (InterruptedException e) { + commandException.addSuppressed(e); + error = true; + } catch (ExecutionException e) { + commandException.addSuppressed(e.getCause()); + error = true; + } + } + if (error) { + throw commandException; + } + return merge(results); + + } + + public abstract T2 merge(Map<TableShardKey, T1> results) throws IOException; + + public abstract Map<TableShardKey, T1> processShard(TableShardKey tableShardKey, BlurIndex blurIndex) + throws IOException; + +} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/486d37b5/blur-core/src/main/java/org/apache/blur/server/platform/CommandClient.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/server/platform/CommandClient.java b/blur-core/src/main/java/org/apache/blur/server/platform/CommandClient.java new file mode 100644 index 0000000..69a48a9 --- /dev/null +++ b/blur-core/src/main/java/org/apache/blur/server/platform/CommandClient.java @@ -0,0 +1,87 @@ +/** + * 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.server.platform; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.blur.thirdparty.thrift_0_9_0.TException; +import org.apache.blur.thrift.generated.AdhocByteCodeCommandRequest; +import org.apache.blur.thrift.generated.AdhocByteCodeCommandResponse; +import org.apache.blur.thrift.generated.Blur.Iface; +import org.apache.blur.thrift.generated.BlurCommandRequest; +import org.apache.blur.thrift.generated.BlurCommandResponse; +import org.apache.blur.thrift.generated.BlurException; +import org.apache.blur.thrift.generated.Value; + +public class CommandClient { + + private final Iface _client; + + public CommandClient(Iface client) { + _client = client; + } + + public <T1, T2> T2 execute(String table, Command<T1, T2> command) throws BlurException, TException, IOException { + Set<String> tables = new HashSet<String>(); + tables.add(table); + return execute(tables, new Object[] {}, command); + } + + public <T1, T2> T2 execute(Set<String> tables, Object[] args, Command<T1, T2> command) throws BlurException, + TException, IOException { + BlurCommandRequest request = new BlurCommandRequest(); + AdhocByteCodeCommandRequest adhocByteCodeCommandRequest = new AdhocByteCodeCommandRequest(); + packCommandAndClasses(adhocByteCodeCommandRequest, args, command); + request.setAdhocByteCodeCommandRequest(adhocByteCodeCommandRequest); + BlurCommandResponse blurCommandResponse = _client.execute(request); + AdhocByteCodeCommandResponse response = blurCommandResponse.getAdhocByteCodeCommandResponse(); + Value result = response.getResult(); + return CommandUtils.toObject(getClass().getClassLoader(), result); + } + + private void packCommandAndClasses(AdhocByteCodeCommandRequest request, Object[] args, Object command) + throws IOException { + request.setClassData(getClassData(getClass())); + request.setInstanceData(CommandUtils.toBytesViaSerialization(command)); + request.setArguments(getArgs(args)); + } + + private List<Value> getArgs(Object[] args) throws IOException { + List<Value> values = new ArrayList<Value>(); + for (Object o : args) { + if (o == null) { + values.add(null); + } else { + values.add(CommandUtils.toValue(o)); + } + } + return values; + } + + private Map<String, ByteBuffer> getClassData(Class<? extends CommandClient> clazz) { + String name = clazz.getName(); + NOT IMPL + return null; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/486d37b5/blur-core/src/main/java/org/apache/blur/server/platform/CommandClientExample.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/server/platform/CommandClientExample.java b/blur-core/src/main/java/org/apache/blur/server/platform/CommandClientExample.java new file mode 100644 index 0000000..7714060 --- /dev/null +++ b/blur-core/src/main/java/org/apache/blur/server/platform/CommandClientExample.java @@ -0,0 +1,54 @@ +/** + * 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.server.platform; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import org.apache.blur.manager.writer.BlurIndex; +import org.apache.blur.thirdparty.thrift_0_9_0.TException; +import org.apache.blur.thrift.BlurClient; +import org.apache.blur.thrift.generated.Blur.Iface; +import org.apache.blur.thrift.generated.BlurException; + +public class CommandClientExample { + + public static void main(String[] args) throws BlurException, TException, IOException { + Iface client = BlurClient.getClient("localhost:40020"); + CommandClient commandClient = new CommandClient(client); + + String str = commandClient.execute("test", new Command<String, String>() { + @Override + public Map<TableShardKey, String> processShard(TableShardKey tableShardKey, BlurIndex blurIndex) + throws IOException { + Map<TableShardKey, String> result = new HashMap<TableShardKey, String>(); + result.put(tableShardKey, "hi"); + return result; + } + + @Override + public String merge(Map<TableShardKey, String> results) throws IOException { + return "hi"; + } + + }); + + System.out.println(str); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/486d37b5/blur-core/src/main/java/org/apache/blur/server/platform/CommandException.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/server/platform/CommandException.java b/blur-core/src/main/java/org/apache/blur/server/platform/CommandException.java new file mode 100644 index 0000000..77e5059 --- /dev/null +++ b/blur-core/src/main/java/org/apache/blur/server/platform/CommandException.java @@ -0,0 +1,23 @@ +/** + * 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.server.platform; + +public class CommandException extends Exception { + + private static final long serialVersionUID = 3664050798263401707L; + +} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/486d37b5/blur-core/src/main/java/org/apache/blur/server/platform/CommandShardServer.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/server/platform/CommandShardServer.java b/blur-core/src/main/java/org/apache/blur/server/platform/CommandShardServer.java new file mode 100644 index 0000000..70643cc --- /dev/null +++ b/blur-core/src/main/java/org/apache/blur/server/platform/CommandShardServer.java @@ -0,0 +1,121 @@ +/** + * 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.server.platform; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.concurrent.ExecutorService; + +import org.apache.blur.manager.IndexServer; +import org.apache.blur.manager.writer.BlurIndex; +import org.apache.blur.thirdparty.thrift_0_9_0.TBaseHelper; +import org.apache.blur.thrift.BException; +import org.apache.blur.thrift.generated.AdhocByteCodeCommandRequest; +import org.apache.blur.thrift.generated.AdhocByteCodeCommandResponse; +import org.apache.blur.thrift.generated.BlurCommandRequest; +import org.apache.blur.thrift.generated.BlurCommandResponse; +import org.apache.blur.thrift.generated.BlurException; +import org.apache.blur.thrift.generated.Value; +import org.codehaus.janino.ByteArrayClassLoader; + +public class CommandShardServer { + + private final IndexServer _indexServer; + private final ExecutorService _executorService; + + public CommandShardServer(IndexServer indexServer, ExecutorService executorService) { + _indexServer = indexServer; + _executorService = executorService; + } + + public <T1, T2> T2 execute(Set<String> tables, Command<T1, T2> command, Set<String> tablesToExecute, Object... args) + throws CommandException, IOException { + command.setArgs(args); + command.setExecutorService(_executorService); + return command.process(getBlurIndexes(tables, tablesToExecute)); + } + + private Map<String, Map<String, BlurIndex>> getBlurIndexes(Set<String> tables, Set<String> tablesToExecute) + throws IOException { + Map<String, Map<String, BlurIndex>> indexes = new HashMap<String, Map<String, BlurIndex>>(); + for (String table : tables) { + Map<String, BlurIndex> map = _indexServer.getIndexes(table); + indexes.put(table, map); + } + return indexes; + } + + public BlurCommandResponse execute(Set<String> tables, BlurCommandRequest request) throws BlurException, IOException, + CommandException { + // @TODO deal with different command types. + Set<String> tablesToInvoke = request.getTablesToInvoke(); + Object fieldValue = request.getFieldValue(); + BlurCommandResponse blurCommandResponse = new BlurCommandResponse(); + if (fieldValue instanceof AdhocByteCodeCommandRequest) { + AdhocByteCodeCommandRequest commandRequest = request.getAdhocByteCodeCommandRequest(); + AdhocByteCodeCommandResponse response = execute(tables, commandRequest, tablesToInvoke); + blurCommandResponse.setAdhocByteCodeCommandResponse(response); + } else { + throw new BException("Not implemented."); + } + return blurCommandResponse; + } + + public AdhocByteCodeCommandResponse execute(Set<String> tables, AdhocByteCodeCommandRequest commandRequest, + Set<String> tablesToInvoke) throws BlurException, IOException, CommandException { + // @TODO handle libraries + + Map<String, ByteBuffer> classData = commandRequest.getClassData(); + ClassLoader classLoader = getClassLoader(classData); + Object[] args = getArgs(classLoader, commandRequest.getArguments()); + Command<?, ?> command = CommandUtils.toObjectViaSerialization(classLoader, commandRequest.getInstanceData()); + Object object = execute(tables, command, tablesToInvoke, args); + Value value = CommandUtils.toValue(object); + + AdhocByteCodeCommandResponse adhocByteCodeCommandResponse = new AdhocByteCodeCommandResponse(); + adhocByteCodeCommandResponse.setResult(value); + return adhocByteCodeCommandResponse; + } + + private ClassLoader getClassLoader(Map<String, ByteBuffer> classData) { + Map<String, byte[]> classDataMap = getClassDataMap(classData); + return new ByteArrayClassLoader(classDataMap); + } + + private Map<String, byte[]> getClassDataMap(Map<String, ByteBuffer> classData) { + Map<String, byte[]> map = new HashMap<String, byte[]>(); + for (Entry<String, ByteBuffer> e : classData.entrySet()) { + map.put(e.getKey(), TBaseHelper.byteBufferToByteArray(e.getValue())); + } + return map; + } + + private Object[] getArgs(ClassLoader classLoader, List<Value> arguments) throws BlurException, IOException { + Object[] args = new Object[arguments.size()]; + int i = 0; + for (Value argument : arguments) { + args[i++] = CommandUtils.toObject(classLoader, argument); + } + return args; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/486d37b5/blur-core/src/main/java/org/apache/blur/server/platform/CommandUtils.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/server/platform/CommandUtils.java b/blur-core/src/main/java/org/apache/blur/server/platform/CommandUtils.java new file mode 100644 index 0000000..43c86e0 --- /dev/null +++ b/blur-core/src/main/java/org/apache/blur/server/platform/CommandUtils.java @@ -0,0 +1,95 @@ +/** + * 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.server.platform; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.ObjectStreamClass; + +import org.apache.blur.thrift.BException; +import org.apache.blur.thrift.generated.BlurException; +import org.apache.blur.thrift.generated.Value; +import org.apache.blur.thrift.generated.ValueType; + +public class CommandUtils { + + public static byte[] toBytesViaSerialization(Object object) throws IOException { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + ObjectOutputStream outputStream = new ObjectOutputStream(out); + outputStream.writeObject(object); + outputStream.close(); + return out.toByteArray(); + } + + public static Value toValue(Object object) throws IOException { + Value value = new Value(); + value.setType(ValueType.SERIALIZABLE); + value.setValue(toBytesViaSerialization(object)); + return value; + } + + @SuppressWarnings("unchecked") + public static <T> T toObjectViaSerialization(ClassLoader classLoader, byte[] instanceData) throws IOException { + CommandObjectInputStream inputStream = new CommandObjectInputStream(classLoader, instanceData); + try { + return (T) inputStream.readObject(); + } catch (ClassNotFoundException e) { + throw new IOException(e); + } finally { + inputStream.close(); + } + } + + public static <T> T toObject(ClassLoader classLoader, Value value) throws BlurException, IOException { + ValueType type = value.getType(); + switch (type) { + case SERIALIZABLE: + return toObjectViaSerialization(classLoader, value.getValue()); + default: + throw new BException("Type [{0}] not supported.", type); + } + } + + public static class CommandObjectInputStream extends ObjectInputStream { + + private final ClassLoader _loader; + + public CommandObjectInputStream(ClassLoader loader, InputStream in) throws IOException { + super(in); + _loader = loader; + } + + public CommandObjectInputStream(ClassLoader classLoader, byte[] bs) throws IOException { + this(classLoader, new ByteArrayInputStream(bs)); + } + + @Override + protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { + String name = desc.getName(); + try { + return Class.forName(name, false, _loader); + } catch (ClassNotFoundException ex) { + return super.resolveClass(desc); + } + } + } + +} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/486d37b5/blur-core/src/main/java/org/apache/blur/server/platform/TableShardKey.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/server/platform/TableShardKey.java b/blur-core/src/main/java/org/apache/blur/server/platform/TableShardKey.java new file mode 100644 index 0000000..2619633 --- /dev/null +++ b/blur-core/src/main/java/org/apache/blur/server/platform/TableShardKey.java @@ -0,0 +1,38 @@ +/** + * 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.server.platform; + +public class TableShardKey { + + private final String _table; + + private final String _shard; + + public TableShardKey(String table, String shard) { + _table = table; + _shard = shard; + } + + public String getTable() { + return _table; + } + + public String getShard() { + return _shard; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/486d37b5/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java b/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java index a1cec15..acc4dfe 100644 --- a/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java +++ b/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java @@ -73,6 +73,8 @@ import org.apache.blur.thirdparty.thrift_0_9_0.transport.TTransport; import org.apache.blur.thrift.commands.BlurCommand; import org.apache.blur.thrift.generated.Blur.Client; import org.apache.blur.thrift.generated.Blur.Iface; +import org.apache.blur.thrift.generated.BlurCommandRequest; +import org.apache.blur.thrift.generated.BlurCommandResponse; import org.apache.blur.thrift.generated.BlurException; import org.apache.blur.thrift.generated.BlurQuery; import org.apache.blur.thrift.generated.BlurQueryStatus; @@ -1507,4 +1509,9 @@ public class BlurControllerServer extends TableAdmin implements Iface { context.setTraceRequestId(requestId); } + @Override + public BlurCommandResponse execute(BlurCommandRequest request) throws BlurException, TException { + throw new BException("Not implemented."); + } + } http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/486d37b5/blur-core/src/main/java/org/apache/blur/thrift/BlurShardServer.java ---------------------------------------------------------------------- diff --git a/blur-core/src/main/java/org/apache/blur/thrift/BlurShardServer.java b/blur-core/src/main/java/org/apache/blur/thrift/BlurShardServer.java index 3ccd577..e6dae12 100644 --- a/blur-core/src/main/java/org/apache/blur/thrift/BlurShardServer.java +++ b/blur-core/src/main/java/org/apache/blur/thrift/BlurShardServer.java @@ -20,8 +20,10 @@ import static org.apache.blur.utils.BlurConstants.BLUR_SHARD_CACHE_MAX_QUERYCACH import static org.apache.blur.utils.BlurConstants.BLUR_SHARD_CACHE_MAX_TIMETOLIVE; import static org.apache.blur.utils.BlurConstants.BLUR_SHARD_DATA_FETCH_THREAD_COUNT; +import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -39,8 +41,12 @@ import org.apache.blur.manager.IndexServer; import org.apache.blur.manager.results.BlurResultIterable; import org.apache.blur.manager.writer.BlurIndex; import org.apache.blur.server.ShardServerContext; +import org.apache.blur.server.platform.CommandException; +import org.apache.blur.server.platform.CommandShardServer; import org.apache.blur.thirdparty.thrift_0_9_0.TException; import org.apache.blur.thrift.generated.Blur.Iface; +import org.apache.blur.thrift.generated.BlurCommandRequest; +import org.apache.blur.thrift.generated.BlurCommandResponse; import org.apache.blur.thrift.generated.BlurException; import org.apache.blur.thrift.generated.BlurQuery; import org.apache.blur.thrift.generated.BlurQueryStatus; @@ -75,6 +81,7 @@ public class BlurShardServer extends TableAdmin implements Iface { private ExecutorService _dataFetch; private String _cluster = BlurConstants.BLUR_CLUSTER; private int _dataFetchThreadCount = 32; + private CommandShardServer _commandShardServer; public void init() throws BlurException { _queryCache = new QueryCache("shard-cache", _maxQueryCacheElements, _maxTimeToLive); @@ -448,6 +455,10 @@ public class BlurShardServer extends TableAdmin implements Iface { _indexServer = indexServer; } + public void setCommandShardServer(CommandShardServer commandShardServer) { + _commandShardServer = commandShardServer; + } + @Override public BlurQueryStatus queryStatusById(String table, String uuid) throws BlurException, TException { try { @@ -583,4 +594,15 @@ public class BlurShardServer extends TableAdmin implements Iface { return false; } + @Override + public BlurCommandResponse execute(BlurCommandRequest request) throws BlurException, TException { + List<String> tableList = tableList(); + try { + return _commandShardServer.execute(new HashSet<String>(tableList), request); + } catch (IOException e) { + throw new BException("Unknown error.", e); + } catch (CommandException e) { + throw new BException("Unknown error.", e); + } + } } http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/486d37b5/blur-thrift/src/main/java/org/apache/blur/thrift/generated/AdhocByteCodeCommandRequest.java ---------------------------------------------------------------------- diff --git a/blur-thrift/src/main/java/org/apache/blur/thrift/generated/AdhocByteCodeCommandRequest.java b/blur-thrift/src/main/java/org/apache/blur/thrift/generated/AdhocByteCodeCommandRequest.java new file mode 100644 index 0000000..7afcfe9 --- /dev/null +++ b/blur-thrift/src/main/java/org/apache/blur/thrift/generated/AdhocByteCodeCommandRequest.java @@ -0,0 +1,886 @@ +/** + * Autogenerated by Thrift Compiler (0.9.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package org.apache.blur.thrift.generated; + +/** + * 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. + */ + + + +import org.apache.blur.thirdparty.thrift_0_9_0.scheme.IScheme; +import org.apache.blur.thirdparty.thrift_0_9_0.scheme.SchemeFactory; +import org.apache.blur.thirdparty.thrift_0_9_0.scheme.StandardScheme; + +import org.apache.blur.thirdparty.thrift_0_9_0.scheme.TupleScheme; +import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TTupleProtocol; +import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolException; +import org.apache.blur.thirdparty.thrift_0_9_0.EncodingUtils; +import org.apache.blur.thirdparty.thrift_0_9_0.TException; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; + +public class AdhocByteCodeCommandRequest implements org.apache.blur.thirdparty.thrift_0_9_0.TBase<AdhocByteCodeCommandRequest, AdhocByteCodeCommandRequest._Fields>, java.io.Serializable, Cloneable { + private static final org.apache.blur.thirdparty.thrift_0_9_0.protocol.TStruct STRUCT_DESC = new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TStruct("AdhocByteCodeCommandRequest"); + + private static final org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField ARGUMENTS_FIELD_DESC = new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField("arguments", org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.LIST, (short)1); + private static final org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField INSTANCE_DATA_FIELD_DESC = new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField("instanceData", org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRING, (short)2); + private static final org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField CLASS_DATA_FIELD_DESC = new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField("classData", org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.MAP, (short)3); + private static final org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField LIBRARIES_FIELD_DESC = new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField("libraries", org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.LIST, (short)4); + + private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new AdhocByteCodeCommandRequestStandardSchemeFactory()); + schemes.put(TupleScheme.class, new AdhocByteCodeCommandRequestTupleSchemeFactory()); + } + + public List<Value> arguments; // required + public ByteBuffer instanceData; // required + public Map<String,ByteBuffer> classData; // required + public List<String> libraries; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.blur.thirdparty.thrift_0_9_0.TFieldIdEnum { + ARGUMENTS((short)1, "arguments"), + INSTANCE_DATA((short)2, "instanceData"), + CLASS_DATA((short)3, "classData"), + LIBRARIES((short)4, "libraries"); + + private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // ARGUMENTS + return ARGUMENTS; + case 2: // INSTANCE_DATA + return INSTANCE_DATA; + case 3: // CLASS_DATA + return CLASS_DATA; + case 4: // LIBRARIES + return LIBRARIES; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.ARGUMENTS, new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData("arguments", org.apache.blur.thirdparty.thrift_0_9_0.TFieldRequirementType.DEFAULT, + new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.ListMetaData(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.LIST, + new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.StructMetaData(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRUCT, Value.class)))); + tmpMap.put(_Fields.INSTANCE_DATA, new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData("instanceData", org.apache.blur.thirdparty.thrift_0_9_0.TFieldRequirementType.DEFAULT, + new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldValueMetaData(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRING , true))); + tmpMap.put(_Fields.CLASS_DATA, new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData("classData", org.apache.blur.thirdparty.thrift_0_9_0.TFieldRequirementType.DEFAULT, + new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.MapMetaData(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.MAP, + new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldValueMetaData(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRING), + new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldValueMetaData(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRING , true)))); + tmpMap.put(_Fields.LIBRARIES, new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData("libraries", org.apache.blur.thirdparty.thrift_0_9_0.TFieldRequirementType.DEFAULT, + new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.ListMetaData(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.LIST, + new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldValueMetaData(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRING)))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData.addStructMetaDataMap(AdhocByteCodeCommandRequest.class, metaDataMap); + } + + public AdhocByteCodeCommandRequest() { + } + + public AdhocByteCodeCommandRequest( + List<Value> arguments, + ByteBuffer instanceData, + Map<String,ByteBuffer> classData, + List<String> libraries) + { + this(); + this.arguments = arguments; + this.instanceData = instanceData; + this.classData = classData; + this.libraries = libraries; + } + + /** + * Performs a deep copy on <i>other</i>. + */ + public AdhocByteCodeCommandRequest(AdhocByteCodeCommandRequest other) { + if (other.isSetArguments()) { + List<Value> __this__arguments = new ArrayList<Value>(); + for (Value other_element : other.arguments) { + __this__arguments.add(new Value(other_element)); + } + this.arguments = __this__arguments; + } + if (other.isSetInstanceData()) { + this.instanceData = org.apache.blur.thirdparty.thrift_0_9_0.TBaseHelper.copyBinary(other.instanceData); +; + } + if (other.isSetClassData()) { + Map<String,ByteBuffer> __this__classData = new HashMap<String,ByteBuffer>(); + for (Map.Entry<String, ByteBuffer> other_element : other.classData.entrySet()) { + + String other_element_key = other_element.getKey(); + ByteBuffer other_element_value = other_element.getValue(); + + String __this__classData_copy_key = other_element_key; + + ByteBuffer __this__classData_copy_value = org.apache.blur.thirdparty.thrift_0_9_0.TBaseHelper.copyBinary(other_element_value); +; + + __this__classData.put(__this__classData_copy_key, __this__classData_copy_value); + } + this.classData = __this__classData; + } + if (other.isSetLibraries()) { + List<String> __this__libraries = new ArrayList<String>(); + for (String other_element : other.libraries) { + __this__libraries.add(other_element); + } + this.libraries = __this__libraries; + } + } + + public AdhocByteCodeCommandRequest deepCopy() { + return new AdhocByteCodeCommandRequest(this); + } + + @Override + public void clear() { + this.arguments = null; + this.instanceData = null; + this.classData = null; + this.libraries = null; + } + + public int getArgumentsSize() { + return (this.arguments == null) ? 0 : this.arguments.size(); + } + + public java.util.Iterator<Value> getArgumentsIterator() { + return (this.arguments == null) ? null : this.arguments.iterator(); + } + + public void addToArguments(Value elem) { + if (this.arguments == null) { + this.arguments = new ArrayList<Value>(); + } + this.arguments.add(elem); + } + + public List<Value> getArguments() { + return this.arguments; + } + + public AdhocByteCodeCommandRequest setArguments(List<Value> arguments) { + this.arguments = arguments; + return this; + } + + public void unsetArguments() { + this.arguments = null; + } + + /** Returns true if field arguments is set (has been assigned a value) and false otherwise */ + public boolean isSetArguments() { + return this.arguments != null; + } + + public void setArgumentsIsSet(boolean value) { + if (!value) { + this.arguments = null; + } + } + + public byte[] getInstanceData() { + setInstanceData(org.apache.blur.thirdparty.thrift_0_9_0.TBaseHelper.rightSize(instanceData)); + return instanceData == null ? null : instanceData.array(); + } + + public ByteBuffer bufferForInstanceData() { + return instanceData; + } + + public AdhocByteCodeCommandRequest setInstanceData(byte[] instanceData) { + setInstanceData(instanceData == null ? (ByteBuffer)null : ByteBuffer.wrap(instanceData)); + return this; + } + + public AdhocByteCodeCommandRequest setInstanceData(ByteBuffer instanceData) { + this.instanceData = instanceData; + return this; + } + + public void unsetInstanceData() { + this.instanceData = null; + } + + /** Returns true if field instanceData is set (has been assigned a value) and false otherwise */ + public boolean isSetInstanceData() { + return this.instanceData != null; + } + + public void setInstanceDataIsSet(boolean value) { + if (!value) { + this.instanceData = null; + } + } + + public int getClassDataSize() { + return (this.classData == null) ? 0 : this.classData.size(); + } + + public void putToClassData(String key, ByteBuffer val) { + if (this.classData == null) { + this.classData = new HashMap<String,ByteBuffer>(); + } + this.classData.put(key, val); + } + + public Map<String,ByteBuffer> getClassData() { + return this.classData; + } + + public AdhocByteCodeCommandRequest setClassData(Map<String,ByteBuffer> classData) { + this.classData = classData; + return this; + } + + public void unsetClassData() { + this.classData = null; + } + + /** Returns true if field classData is set (has been assigned a value) and false otherwise */ + public boolean isSetClassData() { + return this.classData != null; + } + + public void setClassDataIsSet(boolean value) { + if (!value) { + this.classData = null; + } + } + + public int getLibrariesSize() { + return (this.libraries == null) ? 0 : this.libraries.size(); + } + + public java.util.Iterator<String> getLibrariesIterator() { + return (this.libraries == null) ? null : this.libraries.iterator(); + } + + public void addToLibraries(String elem) { + if (this.libraries == null) { + this.libraries = new ArrayList<String>(); + } + this.libraries.add(elem); + } + + public List<String> getLibraries() { + return this.libraries; + } + + public AdhocByteCodeCommandRequest setLibraries(List<String> libraries) { + this.libraries = libraries; + return this; + } + + public void unsetLibraries() { + this.libraries = null; + } + + /** Returns true if field libraries is set (has been assigned a value) and false otherwise */ + public boolean isSetLibraries() { + return this.libraries != null; + } + + public void setLibrariesIsSet(boolean value) { + if (!value) { + this.libraries = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case ARGUMENTS: + if (value == null) { + unsetArguments(); + } else { + setArguments((List<Value>)value); + } + break; + + case INSTANCE_DATA: + if (value == null) { + unsetInstanceData(); + } else { + setInstanceData((ByteBuffer)value); + } + break; + + case CLASS_DATA: + if (value == null) { + unsetClassData(); + } else { + setClassData((Map<String,ByteBuffer>)value); + } + break; + + case LIBRARIES: + if (value == null) { + unsetLibraries(); + } else { + setLibraries((List<String>)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case ARGUMENTS: + return getArguments(); + + case INSTANCE_DATA: + return getInstanceData(); + + case CLASS_DATA: + return getClassData(); + + case LIBRARIES: + return getLibraries(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case ARGUMENTS: + return isSetArguments(); + case INSTANCE_DATA: + return isSetInstanceData(); + case CLASS_DATA: + return isSetClassData(); + case LIBRARIES: + return isSetLibraries(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof AdhocByteCodeCommandRequest) + return this.equals((AdhocByteCodeCommandRequest)that); + return false; + } + + public boolean equals(AdhocByteCodeCommandRequest that) { + if (that == null) + return false; + + boolean this_present_arguments = true && this.isSetArguments(); + boolean that_present_arguments = true && that.isSetArguments(); + if (this_present_arguments || that_present_arguments) { + if (!(this_present_arguments && that_present_arguments)) + return false; + if (!this.arguments.equals(that.arguments)) + return false; + } + + boolean this_present_instanceData = true && this.isSetInstanceData(); + boolean that_present_instanceData = true && that.isSetInstanceData(); + if (this_present_instanceData || that_present_instanceData) { + if (!(this_present_instanceData && that_present_instanceData)) + return false; + if (!this.instanceData.equals(that.instanceData)) + return false; + } + + boolean this_present_classData = true && this.isSetClassData(); + boolean that_present_classData = true && that.isSetClassData(); + if (this_present_classData || that_present_classData) { + if (!(this_present_classData && that_present_classData)) + return false; + if (!this.classData.equals(that.classData)) + return false; + } + + boolean this_present_libraries = true && this.isSetLibraries(); + boolean that_present_libraries = true && that.isSetLibraries(); + if (this_present_libraries || that_present_libraries) { + if (!(this_present_libraries && that_present_libraries)) + return false; + if (!this.libraries.equals(that.libraries)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(AdhocByteCodeCommandRequest other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + AdhocByteCodeCommandRequest typedOther = (AdhocByteCodeCommandRequest)other; + + lastComparison = Boolean.valueOf(isSetArguments()).compareTo(typedOther.isSetArguments()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetArguments()) { + lastComparison = org.apache.blur.thirdparty.thrift_0_9_0.TBaseHelper.compareTo(this.arguments, typedOther.arguments); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetInstanceData()).compareTo(typedOther.isSetInstanceData()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetInstanceData()) { + lastComparison = org.apache.blur.thirdparty.thrift_0_9_0.TBaseHelper.compareTo(this.instanceData, typedOther.instanceData); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetClassData()).compareTo(typedOther.isSetClassData()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetClassData()) { + lastComparison = org.apache.blur.thirdparty.thrift_0_9_0.TBaseHelper.compareTo(this.classData, typedOther.classData); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetLibraries()).compareTo(typedOther.isSetLibraries()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetLibraries()) { + lastComparison = org.apache.blur.thirdparty.thrift_0_9_0.TBaseHelper.compareTo(this.libraries, typedOther.libraries); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol iprot) throws org.apache.blur.thirdparty.thrift_0_9_0.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol oprot) throws org.apache.blur.thirdparty.thrift_0_9_0.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("AdhocByteCodeCommandRequest("); + boolean first = true; + + sb.append("arguments:"); + if (this.arguments == null) { + sb.append("null"); + } else { + sb.append(this.arguments); + } + first = false; + if (!first) sb.append(", "); + sb.append("instanceData:"); + if (this.instanceData == null) { + sb.append("null"); + } else { + org.apache.blur.thirdparty.thrift_0_9_0.TBaseHelper.toString(this.instanceData, sb); + } + first = false; + if (!first) sb.append(", "); + sb.append("classData:"); + if (this.classData == null) { + sb.append("null"); + } else { + sb.append(this.classData); + } + first = false; + if (!first) sb.append(", "); + sb.append("libraries:"); + if (this.libraries == null) { + sb.append("null"); + } else { + sb.append(this.libraries); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.blur.thirdparty.thrift_0_9_0.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TCompactProtocol(new org.apache.blur.thirdparty.thrift_0_9_0.transport.TIOStreamTransport(out))); + } catch (org.apache.blur.thirdparty.thrift_0_9_0.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TCompactProtocol(new org.apache.blur.thirdparty.thrift_0_9_0.transport.TIOStreamTransport(in))); + } catch (org.apache.blur.thirdparty.thrift_0_9_0.TException te) { + throw new java.io.IOException(te); + } + } + + private static class AdhocByteCodeCommandRequestStandardSchemeFactory implements SchemeFactory { + public AdhocByteCodeCommandRequestStandardScheme getScheme() { + return new AdhocByteCodeCommandRequestStandardScheme(); + } + } + + private static class AdhocByteCodeCommandRequestStandardScheme extends StandardScheme<AdhocByteCodeCommandRequest> { + + public void read(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol iprot, AdhocByteCodeCommandRequest struct) throws org.apache.blur.thirdparty.thrift_0_9_0.TException { + org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // ARGUMENTS + if (schemeField.type == org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.LIST) { + { + org.apache.blur.thirdparty.thrift_0_9_0.protocol.TList _list232 = iprot.readListBegin(); + struct.arguments = new ArrayList<Value>(_list232.size); + for (int _i233 = 0; _i233 < _list232.size; ++_i233) + { + Value _elem234; // required + _elem234 = new Value(); + _elem234.read(iprot); + struct.arguments.add(_elem234); + } + iprot.readListEnd(); + } + struct.setArgumentsIsSet(true); + } else { + org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // INSTANCE_DATA + if (schemeField.type == org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRING) { + struct.instanceData = iprot.readBinary(); + struct.setInstanceDataIsSet(true); + } else { + org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // CLASS_DATA + if (schemeField.type == org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.MAP) { + { + org.apache.blur.thirdparty.thrift_0_9_0.protocol.TMap _map235 = iprot.readMapBegin(); + struct.classData = new HashMap<String,ByteBuffer>(2*_map235.size); + for (int _i236 = 0; _i236 < _map235.size; ++_i236) + { + String _key237; // optional + ByteBuffer _val238; // required + _key237 = iprot.readString(); + _val238 = iprot.readBinary(); + struct.classData.put(_key237, _val238); + } + iprot.readMapEnd(); + } + struct.setClassDataIsSet(true); + } else { + org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 4: // LIBRARIES + if (schemeField.type == org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.LIST) { + { + org.apache.blur.thirdparty.thrift_0_9_0.protocol.TList _list239 = iprot.readListBegin(); + struct.libraries = new ArrayList<String>(_list239.size); + for (int _i240 = 0; _i240 < _list239.size; ++_i240) + { + String _elem241; // required + _elem241 = iprot.readString(); + struct.libraries.add(_elem241); + } + iprot.readListEnd(); + } + struct.setLibrariesIsSet(true); + } else { + org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol oprot, AdhocByteCodeCommandRequest struct) throws org.apache.blur.thirdparty.thrift_0_9_0.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.arguments != null) { + oprot.writeFieldBegin(ARGUMENTS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TList(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRUCT, struct.arguments.size())); + for (Value _iter242 : struct.arguments) + { + _iter242.write(oprot); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + if (struct.instanceData != null) { + oprot.writeFieldBegin(INSTANCE_DATA_FIELD_DESC); + oprot.writeBinary(struct.instanceData); + oprot.writeFieldEnd(); + } + if (struct.classData != null) { + oprot.writeFieldBegin(CLASS_DATA_FIELD_DESC); + { + oprot.writeMapBegin(new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TMap(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRING, org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRING, struct.classData.size())); + for (Map.Entry<String, ByteBuffer> _iter243 : struct.classData.entrySet()) + { + oprot.writeString(_iter243.getKey()); + oprot.writeBinary(_iter243.getValue()); + } + oprot.writeMapEnd(); + } + oprot.writeFieldEnd(); + } + if (struct.libraries != null) { + oprot.writeFieldBegin(LIBRARIES_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TList(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRING, struct.libraries.size())); + for (String _iter244 : struct.libraries) + { + oprot.writeString(_iter244); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class AdhocByteCodeCommandRequestTupleSchemeFactory implements SchemeFactory { + public AdhocByteCodeCommandRequestTupleScheme getScheme() { + return new AdhocByteCodeCommandRequestTupleScheme(); + } + } + + private static class AdhocByteCodeCommandRequestTupleScheme extends TupleScheme<AdhocByteCodeCommandRequest> { + + @Override + public void write(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol prot, AdhocByteCodeCommandRequest struct) throws org.apache.blur.thirdparty.thrift_0_9_0.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetArguments()) { + optionals.set(0); + } + if (struct.isSetInstanceData()) { + optionals.set(1); + } + if (struct.isSetClassData()) { + optionals.set(2); + } + if (struct.isSetLibraries()) { + optionals.set(3); + } + oprot.writeBitSet(optionals, 4); + if (struct.isSetArguments()) { + { + oprot.writeI32(struct.arguments.size()); + for (Value _iter245 : struct.arguments) + { + _iter245.write(oprot); + } + } + } + if (struct.isSetInstanceData()) { + oprot.writeBinary(struct.instanceData); + } + if (struct.isSetClassData()) { + { + oprot.writeI32(struct.classData.size()); + for (Map.Entry<String, ByteBuffer> _iter246 : struct.classData.entrySet()) + { + oprot.writeString(_iter246.getKey()); + oprot.writeBinary(_iter246.getValue()); + } + } + } + if (struct.isSetLibraries()) { + { + oprot.writeI32(struct.libraries.size()); + for (String _iter247 : struct.libraries) + { + oprot.writeString(_iter247); + } + } + } + } + + @Override + public void read(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol prot, AdhocByteCodeCommandRequest struct) throws org.apache.blur.thirdparty.thrift_0_9_0.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(4); + if (incoming.get(0)) { + { + org.apache.blur.thirdparty.thrift_0_9_0.protocol.TList _list248 = new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TList(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRUCT, iprot.readI32()); + struct.arguments = new ArrayList<Value>(_list248.size); + for (int _i249 = 0; _i249 < _list248.size; ++_i249) + { + Value _elem250; // required + _elem250 = new Value(); + _elem250.read(iprot); + struct.arguments.add(_elem250); + } + } + struct.setArgumentsIsSet(true); + } + if (incoming.get(1)) { + struct.instanceData = iprot.readBinary(); + struct.setInstanceDataIsSet(true); + } + if (incoming.get(2)) { + { + org.apache.blur.thirdparty.thrift_0_9_0.protocol.TMap _map251 = new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TMap(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRING, org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRING, iprot.readI32()); + struct.classData = new HashMap<String,ByteBuffer>(2*_map251.size); + for (int _i252 = 0; _i252 < _map251.size; ++_i252) + { + String _key253; // optional + ByteBuffer _val254; // required + _key253 = iprot.readString(); + _val254 = iprot.readBinary(); + struct.classData.put(_key253, _val254); + } + } + struct.setClassDataIsSet(true); + } + if (incoming.get(3)) { + { + org.apache.blur.thirdparty.thrift_0_9_0.protocol.TList _list255 = new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TList(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRING, iprot.readI32()); + struct.libraries = new ArrayList<String>(_list255.size); + for (int _i256 = 0; _i256 < _list255.size; ++_i256) + { + String _elem257; // required + _elem257 = iprot.readString(); + struct.libraries.add(_elem257); + } + } + struct.setLibrariesIsSet(true); + } + } + } + +} + http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/486d37b5/blur-thrift/src/main/java/org/apache/blur/thrift/generated/AdhocByteCodeCommandResponse.java ---------------------------------------------------------------------- diff --git a/blur-thrift/src/main/java/org/apache/blur/thrift/generated/AdhocByteCodeCommandResponse.java b/blur-thrift/src/main/java/org/apache/blur/thrift/generated/AdhocByteCodeCommandResponse.java new file mode 100644 index 0000000..9f38edd --- /dev/null +++ b/blur-thrift/src/main/java/org/apache/blur/thrift/generated/AdhocByteCodeCommandResponse.java @@ -0,0 +1,410 @@ +/** + * Autogenerated by Thrift Compiler (0.9.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package org.apache.blur.thrift.generated; + +/** + * 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. + */ + + + +import org.apache.blur.thirdparty.thrift_0_9_0.scheme.IScheme; +import org.apache.blur.thirdparty.thrift_0_9_0.scheme.SchemeFactory; +import org.apache.blur.thirdparty.thrift_0_9_0.scheme.StandardScheme; + +import org.apache.blur.thirdparty.thrift_0_9_0.scheme.TupleScheme; +import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TTupleProtocol; +import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolException; +import org.apache.blur.thirdparty.thrift_0_9_0.EncodingUtils; +import org.apache.blur.thirdparty.thrift_0_9_0.TException; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; + +public class AdhocByteCodeCommandResponse implements org.apache.blur.thirdparty.thrift_0_9_0.TBase<AdhocByteCodeCommandResponse, AdhocByteCodeCommandResponse._Fields>, java.io.Serializable, Cloneable { + private static final org.apache.blur.thirdparty.thrift_0_9_0.protocol.TStruct STRUCT_DESC = new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TStruct("AdhocByteCodeCommandResponse"); + + private static final org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField RESULT_FIELD_DESC = new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField("result", org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRUCT, (short)1); + + private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new AdhocByteCodeCommandResponseStandardSchemeFactory()); + schemes.put(TupleScheme.class, new AdhocByteCodeCommandResponseTupleSchemeFactory()); + } + + public Value result; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.blur.thirdparty.thrift_0_9_0.TFieldIdEnum { + RESULT((short)1, "result"); + + private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // RESULT + return RESULT; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.RESULT, new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData("result", org.apache.blur.thirdparty.thrift_0_9_0.TFieldRequirementType.DEFAULT, + new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.StructMetaData(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRUCT, Value.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData.addStructMetaDataMap(AdhocByteCodeCommandResponse.class, metaDataMap); + } + + public AdhocByteCodeCommandResponse() { + } + + public AdhocByteCodeCommandResponse( + Value result) + { + this(); + this.result = result; + } + + /** + * Performs a deep copy on <i>other</i>. + */ + public AdhocByteCodeCommandResponse(AdhocByteCodeCommandResponse other) { + if (other.isSetResult()) { + this.result = new Value(other.result); + } + } + + public AdhocByteCodeCommandResponse deepCopy() { + return new AdhocByteCodeCommandResponse(this); + } + + @Override + public void clear() { + this.result = null; + } + + public Value getResult() { + return this.result; + } + + public AdhocByteCodeCommandResponse setResult(Value result) { + this.result = result; + return this; + } + + public void unsetResult() { + this.result = null; + } + + /** Returns true if field result is set (has been assigned a value) and false otherwise */ + public boolean isSetResult() { + return this.result != null; + } + + public void setResultIsSet(boolean value) { + if (!value) { + this.result = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case RESULT: + if (value == null) { + unsetResult(); + } else { + setResult((Value)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case RESULT: + return getResult(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case RESULT: + return isSetResult(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof AdhocByteCodeCommandResponse) + return this.equals((AdhocByteCodeCommandResponse)that); + return false; + } + + public boolean equals(AdhocByteCodeCommandResponse that) { + if (that == null) + return false; + + boolean this_present_result = true && this.isSetResult(); + boolean that_present_result = true && that.isSetResult(); + if (this_present_result || that_present_result) { + if (!(this_present_result && that_present_result)) + return false; + if (!this.result.equals(that.result)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(AdhocByteCodeCommandResponse other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + AdhocByteCodeCommandResponse typedOther = (AdhocByteCodeCommandResponse)other; + + lastComparison = Boolean.valueOf(isSetResult()).compareTo(typedOther.isSetResult()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetResult()) { + lastComparison = org.apache.blur.thirdparty.thrift_0_9_0.TBaseHelper.compareTo(this.result, typedOther.result); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol iprot) throws org.apache.blur.thirdparty.thrift_0_9_0.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol oprot) throws org.apache.blur.thirdparty.thrift_0_9_0.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("AdhocByteCodeCommandResponse("); + boolean first = true; + + sb.append("result:"); + if (this.result == null) { + sb.append("null"); + } else { + sb.append(this.result); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.blur.thirdparty.thrift_0_9_0.TException { + // check for required fields + // check for sub-struct validity + if (result != null) { + result.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TCompactProtocol(new org.apache.blur.thirdparty.thrift_0_9_0.transport.TIOStreamTransport(out))); + } catch (org.apache.blur.thirdparty.thrift_0_9_0.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TCompactProtocol(new org.apache.blur.thirdparty.thrift_0_9_0.transport.TIOStreamTransport(in))); + } catch (org.apache.blur.thirdparty.thrift_0_9_0.TException te) { + throw new java.io.IOException(te); + } + } + + private static class AdhocByteCodeCommandResponseStandardSchemeFactory implements SchemeFactory { + public AdhocByteCodeCommandResponseStandardScheme getScheme() { + return new AdhocByteCodeCommandResponseStandardScheme(); + } + } + + private static class AdhocByteCodeCommandResponseStandardScheme extends StandardScheme<AdhocByteCodeCommandResponse> { + + public void read(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol iprot, AdhocByteCodeCommandResponse struct) throws org.apache.blur.thirdparty.thrift_0_9_0.TException { + org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // RESULT + if (schemeField.type == org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRUCT) { + struct.result = new Value(); + struct.result.read(iprot); + struct.setResultIsSet(true); + } else { + org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol oprot, AdhocByteCodeCommandResponse struct) throws org.apache.blur.thirdparty.thrift_0_9_0.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.result != null) { + oprot.writeFieldBegin(RESULT_FIELD_DESC); + struct.result.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class AdhocByteCodeCommandResponseTupleSchemeFactory implements SchemeFactory { + public AdhocByteCodeCommandResponseTupleScheme getScheme() { + return new AdhocByteCodeCommandResponseTupleScheme(); + } + } + + private static class AdhocByteCodeCommandResponseTupleScheme extends TupleScheme<AdhocByteCodeCommandResponse> { + + @Override + public void write(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol prot, AdhocByteCodeCommandResponse struct) throws org.apache.blur.thirdparty.thrift_0_9_0.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetResult()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetResult()) { + struct.result.write(oprot); + } + } + + @Override + public void read(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol prot, AdhocByteCodeCommandResponse struct) throws org.apache.blur.thirdparty.thrift_0_9_0.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.result = new Value(); + struct.result.read(iprot); + struct.setResultIsSet(true); + } + } + } + +} +
