drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adene...@apache.org
Subject [1/3] drill git commit: DRILL-4369: Exchange name and version infos during handshake
Date Wed, 19 Oct 2016 22:52:53 GMT
Repository: drill
Updated Branches:
  refs/heads/master db4829892 -> 13f21e14b


http://git-wip-us.apache.org/repos/asf/drill/blob/13f21e14/protocol/src/main/java/org/apache/drill/exec/proto/beans/BitToUserHandshake.java
----------------------------------------------------------------------
diff --git a/protocol/src/main/java/org/apache/drill/exec/proto/beans/BitToUserHandshake.java
b/protocol/src/main/java/org/apache/drill/exec/proto/beans/BitToUserHandshake.java
index 20c6de1..dc42289 100644
--- a/protocol/src/main/java/org/apache/drill/exec/proto/beans/BitToUserHandshake.java
+++ b/protocol/src/main/java/org/apache/drill/exec/proto/beans/BitToUserHandshake.java
@@ -51,6 +51,7 @@ public final class BitToUserHandshake implements Externalizable, Message<BitToUs
     private HandshakeStatus status;
     private String errorId;
     private String errorMessage;
+    private RpcEndpointInfos serverInfos;
 
     public BitToUserHandshake()
     {
@@ -111,6 +112,19 @@ public final class BitToUserHandshake implements Externalizable, Message<BitToUs
         return this;
     }
 
+    // serverInfos
+
+    public RpcEndpointInfos getServerInfos()
+    {
+        return serverInfos;
+    }
+
+    public BitToUserHandshake setServerInfos(RpcEndpointInfos serverInfos)
+    {
+        this.serverInfos = serverInfos;
+        return this;
+    }
+
     // java serialization
 
     public void readExternal(ObjectInput in) throws IOException
@@ -177,6 +191,10 @@ public final class BitToUserHandshake implements Externalizable, Message<BitToUs
                 case 5:
                     message.errorMessage = input.readString();
                     break;
+                case 6:
+                    message.serverInfos = input.mergeObject(message.serverInfos, RpcEndpointInfos.getSchema());
+                    break;
+
                 default:
                     input.handleUnknownField(number, this);
             }   
@@ -197,6 +215,10 @@ public final class BitToUserHandshake implements Externalizable, Message<BitToUs
 
         if(message.errorMessage != null)
             output.writeString(5, message.errorMessage, false);
+
+        if(message.serverInfos != null)
+             output.writeObject(6, message.serverInfos, RpcEndpointInfos.getSchema(), false);
+
     }
 
     public String getFieldName(int number)
@@ -207,6 +229,7 @@ public final class BitToUserHandshake implements Externalizable, Message<BitToUs
             case 3: return "status";
             case 4: return "errorId";
             case 5: return "errorMessage";
+            case 6: return "serverInfos";
             default: return null;
         }
     }
@@ -224,6 +247,7 @@ public final class BitToUserHandshake implements Externalizable, Message<BitToUs
         __fieldMap.put("status", 3);
         __fieldMap.put("errorId", 4);
         __fieldMap.put("errorMessage", 5);
+        __fieldMap.put("serverInfos", 6);
     }
     
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/13f21e14/protocol/src/main/java/org/apache/drill/exec/proto/beans/RpcEndpointInfos.java
----------------------------------------------------------------------
diff --git a/protocol/src/main/java/org/apache/drill/exec/proto/beans/RpcEndpointInfos.java
b/protocol/src/main/java/org/apache/drill/exec/proto/beans/RpcEndpointInfos.java
new file mode 100644
index 0000000..9849e56
--- /dev/null
+++ b/protocol/src/main/java/org/apache/drill/exec/proto/beans/RpcEndpointInfos.java
@@ -0,0 +1,273 @@
+/**
+ * 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.
+ */
+// Generated by http://code.google.com/p/protostuff/ ... DO NOT EDIT!
+// Generated from protobuf
+
+package org.apache.drill.exec.proto.beans;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import com.dyuproject.protostuff.GraphIOUtil;
+import com.dyuproject.protostuff.Input;
+import com.dyuproject.protostuff.Message;
+import com.dyuproject.protostuff.Output;
+import com.dyuproject.protostuff.Schema;
+
+public final class RpcEndpointInfos implements Externalizable, Message<RpcEndpointInfos>,
Schema<RpcEndpointInfos>
+{
+
+    public static Schema<RpcEndpointInfos> getSchema()
+    {
+        return DEFAULT_INSTANCE;
+    }
+
+    public static RpcEndpointInfos getDefaultInstance()
+    {
+        return DEFAULT_INSTANCE;
+    }
+
+    static final RpcEndpointInfos DEFAULT_INSTANCE = new RpcEndpointInfos();
+
+    
+    private String name;
+    private String version;
+    private int majorVersion;
+    private int minorVersion;
+    private int patchVersion;
+    private String application;
+
+    public RpcEndpointInfos()
+    {
+        
+    }
+
+    // getters and setters
+
+    // name
+
+    public String getName()
+    {
+        return name;
+    }
+
+    public RpcEndpointInfos setName(String name)
+    {
+        this.name = name;
+        return this;
+    }
+
+    // version
+
+    public String getVersion()
+    {
+        return version;
+    }
+
+    public RpcEndpointInfos setVersion(String version)
+    {
+        this.version = version;
+        return this;
+    }
+
+    // majorVersion
+
+    public int getMajorVersion()
+    {
+        return majorVersion;
+    }
+
+    public RpcEndpointInfos setMajorVersion(int majorVersion)
+    {
+        this.majorVersion = majorVersion;
+        return this;
+    }
+
+    // minorVersion
+
+    public int getMinorVersion()
+    {
+        return minorVersion;
+    }
+
+    public RpcEndpointInfos setMinorVersion(int minorVersion)
+    {
+        this.minorVersion = minorVersion;
+        return this;
+    }
+
+    // patchVersion
+
+    public int getPatchVersion()
+    {
+        return patchVersion;
+    }
+
+    public RpcEndpointInfos setPatchVersion(int patchVersion)
+    {
+        this.patchVersion = patchVersion;
+        return this;
+    }
+
+    // application
+
+    public String getApplication()
+    {
+        return application;
+    }
+
+    public RpcEndpointInfos setApplication(String application)
+    {
+        this.application = application;
+        return this;
+    }
+
+    // java serialization
+
+    public void readExternal(ObjectInput in) throws IOException
+    {
+        GraphIOUtil.mergeDelimitedFrom(in, this, this);
+    }
+
+    public void writeExternal(ObjectOutput out) throws IOException
+    {
+        GraphIOUtil.writeDelimitedTo(out, this, this);
+    }
+
+    // message method
+
+    public Schema<RpcEndpointInfos> cachedSchema()
+    {
+        return DEFAULT_INSTANCE;
+    }
+
+    // schema methods
+
+    public RpcEndpointInfos newMessage()
+    {
+        return new RpcEndpointInfos();
+    }
+
+    public Class<RpcEndpointInfos> typeClass()
+    {
+        return RpcEndpointInfos.class;
+    }
+
+    public String messageName()
+    {
+        return RpcEndpointInfos.class.getSimpleName();
+    }
+
+    public String messageFullName()
+    {
+        return RpcEndpointInfos.class.getName();
+    }
+
+    public boolean isInitialized(RpcEndpointInfos message)
+    {
+        return true;
+    }
+
+    public void mergeFrom(Input input, RpcEndpointInfos message) throws IOException
+    {
+        for(int number = input.readFieldNumber(this);; number = input.readFieldNumber(this))
+        {
+            switch(number)
+            {
+                case 0:
+                    return;
+                case 1:
+                    message.name = input.readString();
+                    break;
+                case 2:
+                    message.version = input.readString();
+                    break;
+                case 3:
+                    message.majorVersion = input.readUInt32();
+                    break;
+                case 4:
+                    message.minorVersion = input.readUInt32();
+                    break;
+                case 5:
+                    message.patchVersion = input.readUInt32();
+                    break;
+                case 6:
+                    message.application = input.readString();
+                    break;
+                default:
+                    input.handleUnknownField(number, this);
+            }   
+        }
+    }
+
+
+    public void writeTo(Output output, RpcEndpointInfos message) throws IOException
+    {
+        if(message.name != null)
+            output.writeString(1, message.name, false);
+
+        if(message.version != null)
+            output.writeString(2, message.version, false);
+
+        if(message.majorVersion != 0)
+            output.writeUInt32(3, message.majorVersion, false);
+
+        if(message.minorVersion != 0)
+            output.writeUInt32(4, message.minorVersion, false);
+
+        if(message.patchVersion != 0)
+            output.writeUInt32(5, message.patchVersion, false);
+
+        if(message.application != null)
+            output.writeString(6, message.application, false);
+    }
+
+    public String getFieldName(int number)
+    {
+        switch(number)
+        {
+            case 1: return "name";
+            case 2: return "version";
+            case 3: return "majorVersion";
+            case 4: return "minorVersion";
+            case 5: return "patchVersion";
+            case 6: return "application";
+            default: return null;
+        }
+    }
+
+    public int getFieldNumber(String name)
+    {
+        final Integer number = __fieldMap.get(name);
+        return number == null ? 0 : number.intValue();
+    }
+
+    private static final java.util.HashMap<String,Integer> __fieldMap = new java.util.HashMap<String,Integer>();
+    static
+    {
+        __fieldMap.put("name", 1);
+        __fieldMap.put("version", 2);
+        __fieldMap.put("majorVersion", 3);
+        __fieldMap.put("minorVersion", 4);
+        __fieldMap.put("patchVersion", 5);
+        __fieldMap.put("application", 6);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/13f21e14/protocol/src/main/java/org/apache/drill/exec/proto/beans/UserToBitHandshake.java
----------------------------------------------------------------------
diff --git a/protocol/src/main/java/org/apache/drill/exec/proto/beans/UserToBitHandshake.java
b/protocol/src/main/java/org/apache/drill/exec/proto/beans/UserToBitHandshake.java
index efd8e58..7f524fe 100644
--- a/protocol/src/main/java/org/apache/drill/exec/proto/beans/UserToBitHandshake.java
+++ b/protocol/src/main/java/org/apache/drill/exec/proto/beans/UserToBitHandshake.java
@@ -56,6 +56,7 @@ public final class UserToBitHandshake implements Externalizable, Message<UserToB
     private UserProperties properties;
     private Boolean supportComplexTypes = DEFAULT_SUPPORT_COMPLEX_TYPES;
     private Boolean supportTimeout = DEFAULT_SUPPORT_TIMEOUT;
+    private RpcEndpointInfos clientInfos;
 
     public UserToBitHandshake()
     {
@@ -155,6 +156,19 @@ public final class UserToBitHandshake implements Externalizable, Message<UserToB
         return this;
     }
 
+    // clientInfos
+
+    public RpcEndpointInfos getClientInfos()
+    {
+        return clientInfos;
+    }
+
+    public UserToBitHandshake setClientInfos(RpcEndpointInfos clientInfos)
+    {
+        this.clientInfos = clientInfos;
+        return this;
+    }
+
     // java serialization
 
     public void readExternal(ObjectInput in) throws IOException
@@ -232,6 +246,10 @@ public final class UserToBitHandshake implements Externalizable, Message<UserToB
                 case 7:
                     message.supportTimeout = input.readBool();
                     break;
+                case 8:
+                    message.clientInfos = input.mergeObject(message.clientInfos, RpcEndpointInfos.getSchema());
+                    break;
+
                 default:
                     input.handleUnknownField(number, this);
             }   
@@ -263,6 +281,10 @@ public final class UserToBitHandshake implements Externalizable, Message<UserToB
 
         if(message.supportTimeout != null && message.supportTimeout != DEFAULT_SUPPORT_TIMEOUT)
             output.writeBool(7, message.supportTimeout, false);
+
+        if(message.clientInfos != null)
+             output.writeObject(8, message.clientInfos, RpcEndpointInfos.getSchema(), false);
+
     }
 
     public String getFieldName(int number)
@@ -276,6 +298,7 @@ public final class UserToBitHandshake implements Externalizable, Message<UserToB
             case 5: return "properties";
             case 6: return "supportComplexTypes";
             case 7: return "supportTimeout";
+            case 8: return "clientInfos";
             default: return null;
         }
     }
@@ -296,6 +319,7 @@ public final class UserToBitHandshake implements Externalizable, Message<UserToB
         __fieldMap.put("properties", 5);
         __fieldMap.put("supportComplexTypes", 6);
         __fieldMap.put("supportTimeout", 7);
+        __fieldMap.put("clientInfos", 8);
     }
     
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/13f21e14/protocol/src/main/protobuf/User.proto
----------------------------------------------------------------------
diff --git a/protocol/src/main/protobuf/User.proto b/protocol/src/main/protobuf/User.proto
index 62c401a..fe8dc3d 100644
--- a/protocol/src/main/protobuf/User.proto
+++ b/protocol/src/main/protobuf/User.proto
@@ -54,6 +54,15 @@ message UserProperties {
   repeated Property properties = 1;
 }
 
+message RpcEndpointInfos {
+    optional string name = 1;           // example: Apache Drill Server, Apache Drill C++
client
+    optional string version = 2;        // example: 1.9.0
+    optional uint32 majorVersion = 3;   // example: 1
+    optional uint32 minorVersion = 4;   // example: 9
+    optional uint32 patchVersion = 5;   // example: 0
+    optional string application = 6;    // example: Tableau 9.3
+}
+
 message UserToBitHandshake {
   optional exec.shared.RpcChannel channel = 1 [default = USER];
   optional bool support_listening = 2;
@@ -62,6 +71,7 @@ message UserToBitHandshake {
   optional UserProperties properties = 5;
   optional bool support_complex_types = 6 [default = false];
   optional bool support_timeout = 7 [default = false];
+  optional RpcEndpointInfos client_infos = 8;
 }
 
 message RequestResults {
@@ -100,6 +110,7 @@ message BitToUserHandshake {
   optional HandshakeStatus status = 3;
   optional string errorId = 4;
   optional string errorMessage = 5;
+  optional RpcEndpointInfos server_infos = 6;
 }
 
 /*

http://git-wip-us.apache.org/repos/asf/drill/blob/13f21e14/tools/fmpp/src/main/java/org/apache/drill/fmpp/mojo/FMPPMojo.java
----------------------------------------------------------------------
diff --git a/tools/fmpp/src/main/java/org/apache/drill/fmpp/mojo/FMPPMojo.java b/tools/fmpp/src/main/java/org/apache/drill/fmpp/mojo/FMPPMojo.java
index 6f3833f..2d70c64 100644
--- a/tools/fmpp/src/main/java/org/apache/drill/fmpp/mojo/FMPPMojo.java
+++ b/tools/fmpp/src/main/java/org/apache/drill/fmpp/mojo/FMPPMojo.java
@@ -25,6 +25,7 @@ import java.nio.file.Files;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.drill.fmpp.mojo.MavenDataLoader.MavenData;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
@@ -62,7 +63,6 @@ public class FMPPMojo extends AbstractMojo {
    */
   private File templates;
 
-
   /**
    * Where to write the generated files of the output files.
    *
@@ -87,6 +87,14 @@ public class FMPPMojo extends AbstractMojo {
    */
   private String scope;
 
+  /**
+   * if maven properties are added as data
+   *
+   * @parameter default-value="true"
+   * @required
+   */
+  private boolean addMavenDataLoader;
+
   @Override
   public void execute() throws MojoExecutionException, MojoFailureException {
     if (project == null) {
@@ -121,8 +129,8 @@ public class FMPPMojo extends AbstractMojo {
       String tmpPath = tmp.getAbsolutePath();
       final String tmpPathNormalized = tmpPath.endsWith(File.separator) ? tmpPath : tmpPath
+ File.separator;
       Settings settings = new Settings(new File("."));
-      settings.set("sourceRoot", templatesPath);
-      settings.set("outputRoot", tmp.getAbsolutePath());
+      settings.set(Settings.NAME_SOURCE_ROOT, templatesPath);
+      settings.set(Settings.NAME_OUTPUT_ROOT, tmp.getAbsolutePath());
       settings.load(config);
       settings.addProgressListener(new TerseConsoleProgressListener());
       settings.addProgressListener(new ProgressListener() {
@@ -146,6 +154,11 @@ public class FMPPMojo extends AbstractMojo {
           }
         }
       } );
+      if (addMavenDataLoader) {
+        getLog().info("Adding maven data loader");
+        settings.setEngineAttribute(MavenDataLoader.MAVEN_DATA_ATTRIBUTE, new MavenData(project));
+        settings.add(Settings.NAME_DATA, format("maven: %s()", MavenDataLoader.class.getName()));
+      }
       settings.execute();
     } catch (Exception e) {
       throw new MojoFailureException(MiscUtil.causeMessages(e), e);

http://git-wip-us.apache.org/repos/asf/drill/blob/13f21e14/tools/fmpp/src/main/java/org/apache/drill/fmpp/mojo/MavenDataLoader.java
----------------------------------------------------------------------
diff --git a/tools/fmpp/src/main/java/org/apache/drill/fmpp/mojo/MavenDataLoader.java b/tools/fmpp/src/main/java/org/apache/drill/fmpp/mojo/MavenDataLoader.java
new file mode 100644
index 0000000..c330c25
--- /dev/null
+++ b/tools/fmpp/src/main/java/org/apache/drill/fmpp/mojo/MavenDataLoader.java
@@ -0,0 +1,55 @@
+/*
+ * 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.drill.fmpp.mojo;
+
+import java.util.List;
+
+import org.apache.maven.project.MavenProject;
+
+import fmpp.Engine;
+import fmpp.tdd.DataLoader;
+
+/**
+ * A data loader for Maven
+ */
+public class MavenDataLoader implements DataLoader {
+  public static final class MavenData {
+    private final MavenProject project;
+
+    public MavenData(MavenProject project) {
+      this.project = project;
+    }
+
+    public MavenProject getProject() {
+      return project;
+    }
+  }
+
+  public static final String  MAVEN_DATA_ATTRIBUTE = "maven.data";
+
+  @Override
+  public Object load(Engine e, List args) throws Exception {
+    if (!args.isEmpty()) {
+      throw new IllegalArgumentException("maven model data loader has no parameters");
+    }
+
+    MavenData data = (MavenData) e.getAttribute(MAVEN_DATA_ATTRIBUTE);
+    return data;
+  }
+
+}


Mime
View raw message