从聚合物前端访问Apache Zeppelin websocket服务器

时间:2016-11-25 07:21:24

标签: websocket polymer apache-zeppelin

该问题的一点背景: 我公司要求从笔记本级别连接到zeppelin web-server并执行一些基本操作,如保存,运行和编辑段落。我还必须使用这些段落创建一些自定义可视化。基础项目在Google Polymer中,我一直使用https://github.com/hph/web-socket/作为我的websocket组件。

我的前端在端口'3000'中运行并与位于=>的zeppelin websocket服务器通信WS://本地主机:8080 / WS /

现在问题是,'GET_NOTE'操作正常; 'COMMIT_PARAGRAPH'操作正常。但'RUN_PARAGRAPH'永远不会有效,它只返回=>状态: “ERROR”

Zeppelin版试用:0.6.0和0.6.1。 这是我的有效负载和websocket标记:

// payload sent to server to run paragraph
var payload = {
   "op":"RUN_PARAGRAPH",
   "principal":"anonymous",
   "roles":"[]",
   "data":{
      "config":{
         "colWidth":11,
         "graph":{
            "mode":"scatterChart",
            "height":300,
            "optionOpen":false,
            "keys":[
               {
                  "name":"a",
                  "index":0,
                  "aggr":"sum"
               }
            ],
            "values":[
               {
                  "name":"b",
                  "index":1,
                  "aggr":"sum"
               }
            ],
            "groups":[

            ],
            "scatter":{
               "xAxis":{
                  "name":"a",
                  "index":0,
                  "aggr":"sum"
               },
               "yAxis":{
                  "name":"b",
                  "index":1,
                  "aggr":"sum"
               }
            },
            "polymerD3":{
               "selectedChart":{
                  "label":"Stacked Bar Chart",
                  "icon":"editor:insert-chart",
                  "element":"bar-chart",
                  "callBack":"initStackedBarChart",
                  "settings":{
                     "area":[
                        {
                           "input":"height",
                           "txt":"Height of the chart",
                           "uitype":"Number",
                           "selectedValue":500,
                           "callBack":"chartHeightCb"
                        },
                        {
                           "input":"width",
                           "txt":"Width of the chart",
                           "uitype":"Number",
                           "selectedValue":960
                        },
                        {
                           "input":"marginTop",
                           "txt":"Top  margin",
                           "uitype":"Number",
                           "selectedValue":40
                        },
                        {
                           "input":"marginRight",
                           "txt":"Right margin",
                           "uitype":"Number",
                           "selectedValue":10
                        },
                        {
                           "input":"marginBottom",
                           "txt":"Bottom margin",
                           "uitype":"Number",
                           "selectedValue":20
                        },
                        {
                           "input":"marginLeft",
                           "txt":"Left margin",
                           "uitype":"Number",
                           "selectedValue":50
                        },
                        {
                           "input":"strokeWidth",
                           "txt":"Stroke Width",
                           "uitype":"Number",
                           "selectedValue":0,
                           "callBack":"strokeWidthCb"
                        },
                        {
                           "input":"xAxisRotation",
                           "txt":"Rotate X-Axis Tick",
                           "uitype":"sliderInput",
                           "selectedValue":0,
                           "min":-90,
                           "max":90,
                           "step":15,
                           "callBack":"xAxisRotationCb"
                        },
                        {
                           "input":"yAxisRotation",
                           "txt":"Rotate Y-Axis Tick",
                           "uitype":"sliderInput",
                           "selectedValue":0,
                           "min":-60,
                           "max":60,
                           "step":12,
                           "callBack":"yAxisRotationCb"
                        }
                     ],
                     "inputs":[
                        {
                           "input":"x",
                           "txt":"Pick Dimension",
                           "selectedValue":[
                              0
                           ],
                           "scaleType":"",
                           "format":"",
                           "selectedObjs":[
                              {
                                 "key":"a",
                                 "value":0,
                                 "type":"Number"
                              }
                           ],
                           "uitype":"single-value",
                           "displayName":"myXAxis",
                           "maxSelectableValues":1
                        },
                        {
                           "input":"y",
                           "txt":"Pick Measures",
                           "selectedValue":[
                              1
                           ],
                           "format":"",
                           "scaleType":"",
                           "selectedObjs":[
                              {
                                 "key":"b",
                                 "value":1,
                                 "type":"Number"
                              }
                           ],
                           "uitype":"multi-value",
                           "displayName":"myYAxis",
                           "maxSelectableValues":2
                        },
                        {
                           "input":"z",
                           "txt":"Pick Z",
                           "selectedValue":[

                           ],
                           "format":"",
                           "scaleType":"",
                           "selectedObjs":[

                           ],
                           "uitype":"multi-value",
                           "displayName":"myZAxis",
                           "maxSelectableValues":2
                        }
                     ],
                     "legendSettings":{
                        "background":"white",
                        "posX":50,
                        "posY":30,
                        "text":"blue",
                        "colors":[
                           {
                              "color":"#c452b2",
                              "label":"b"
                           }
                        ]
                     }
                  }
               },
               "availableCharts":[
                  {
                     "label":"Stacked Bar Chart",
                     "icon":"editor:insert-chart",
                     "element":"bar-chart",
                     "callBack":"initStackedBarChart",
                     "settings":{
                        "area":[
                           {
                              "input":"height",
                              "txt":"Height of the chart",
                              "uitype":"Number",
                              "selectedValue":500,
                              "callBack":"chartHeightCb"
                           },
                           {
                              "input":"width",
                              "txt":"Width of the chart",
                              "uitype":"Number",
                              "selectedValue":960
                           },
                           {
                              "input":"marginTop",
                              "txt":"Top  margin",
                              "uitype":"Number",
                              "selectedValue":40
                           },
                           {
                              "input":"marginRight",
                              "txt":"Right margin",
                              "uitype":"Number",
                              "selectedValue":10
                           },
                           {
                              "input":"marginBottom",
                              "txt":"Bottom margin",
                              "uitype":"Number",
                              "selectedValue":20
                           },
                           {
                              "input":"marginLeft",
                              "txt":"Left margin",
                              "uitype":"Number",
                              "selectedValue":50
                           },
                           {
                              "input":"strokeWidth",
                              "txt":"Stroke Width",
                              "uitype":"Number",
                              "selectedValue":0,
                              "callBack":"strokeWidthCb"
                           },
                           {
                              "input":"xAxisRotation",
                              "txt":"Rotate X-Axis Tick",
                              "uitype":"sliderInput",
                              "selectedValue":0,
                              "min":-90,
                              "max":90,
                              "step":15,
                              "callBack":"xAxisRotationCb"
                           },
                           {
                              "input":"yAxisRotation",
                              "txt":"Rotate Y-Axis Tick",
                              "uitype":"sliderInput",
                              "selectedValue":0,
                              "min":-60,
                              "max":60,
                              "step":12,
                              "callBack":"yAxisRotationCb"
                           }
                        ],
                        "inputs":[
                           {
                              "input":"x",
                              "txt":"Pick Dimension",
                              "selectedValue":[
                                 0
                              ],
                              "scaleType":"",
                              "format":"",
                              "selectedObjs":[
                                 {
                                    "key":"a",
                                    "value":0,
                                    "type":"Number"
                                 }
                              ],
                              "uitype":"single-value",
                              "displayName":"myXAxis",
                              "maxSelectableValues":1
                           },
                           {
                              "input":"y",
                              "txt":"Pick Measures",
                              "selectedValue":[
                                 1
                              ],
                              "format":"",
                              "scaleType":"",
                              "selectedObjs":[
                                 {
                                    "key":"b",
                                    "value":1,
                                    "type":"Number"
                                 }
                              ],
                              "uitype":"multi-value",
                              "displayName":"myYAxis",
                              "maxSelectableValues":2
                           },
                           {
                              "input":"z",
                              "txt":"Pick Z",
                              "selectedValue":[

                              ],
                              "format":"",
                              "scaleType":"",
                              "selectedObjs":[

                              ],
                              "uitype":"multi-value",
                              "displayName":"myZAxis",
                              "maxSelectableValues":2
                           }
                        ],
                        "legendSettings":{
                           "background":"white",
                           "posX":50,
                           "posY":30,
                           "text":"blue",
                           "colors":[
                              {
                                 "color":"#c452b2",
                                 "label":"b"
                              }
                           ]
                        }
                     }
                  },
                  {
                     "label":"Grouped Bar Chart",
                     "icon":"icons:cloud-circle",
                     "element":"bar-chart",
                     "callBack":"initGroupedBarChart",
                     "settings":{
                        "area":[
                           {
                              "input":"height",
                              "txt":"Height of the chart",
                              "uitype":"Number",
                              "selectedValue":500,
                              "callBack":"chartHeightCb"
                           },
                           {
                              "input":"width",
                              "txt":"Width of the chart",
                              "uitype":"Number",
                              "selectedValue":960
                           },
                           {
                              "input":"marginTop",
                              "txt":"Top  margin",
                              "uitype":"Number",
                              "selectedValue":40
                           },
                           {
                              "input":"marginRight",
                              "txt":"Right margin",
                              "uitype":"Number",
                              "selectedValue":10
                           },
                           {
                              "input":"marginBottom",
                              "txt":"Bottom margin",
                              "uitype":"Number",
                              "selectedValue":20
                           },
                           {
                              "input":"marginLeft",
                              "txt":"Left margin",
                              "uitype":"Number",
                              "selectedValue":50
                           },
                           {
                              "input":"strokeWidth",
                              "txt":"Stroke Width",
                              "uitype":"Number",
                              "selectedValue":0,
                              "callBack":"strokeWidthCb"
                           },
                           {
                              "input":"xAxisRotation",
                              "txt":"Rotate X-Axis Tick",
                              "uitype":"sliderInput",
                              "selectedValue":0,
                              "min":-90,
                              "max":90,
                              "step":15,
                              "callBack":"xAxisRotationCb"
                           },
                           {
                              "input":"yAxisRotation",
                              "txt":"Rotate Y-Axis Tick",
                              "uitype":"sliderInput",
                              "selectedValue":0,
                              "min":-60,
                              "max":60,
                              "step":12,
                              "callBack":"yAxisRotationCb"
                           }
                        ],
                        "inputs":[
                           {
                              "input":"x",
                              "txt":"Pick Dimension",
                              "selectedValue":[

                              ],
                              "scaleType":"",
                              "format":"",
                              "selectedObjs":[

                              ],
                              "uitype":"single-value",
                              "displayName":"myXAxis",
                              "maxSelectableValues":1
                           },
                           {
                              "input":"y",
                              "txt":"Pick Measures",
                              "selectedValue":[

                              ],
                              "format":"",
                              "scaleType":"",
                              "selectedObjs":[

                              ],
                              "uitype":"multi-value",
                              "displayName":"myYAxis",
                              "maxSelectableValues":2
                           },
                           {
                              "input":"z",
                              "txt":"Pick Z",
                              "selectedValue":[

                              ],
                              "format":"",
                              "scaleType":"",
                              "selectedObjs":[

                              ],
                              "uitype":"multi-value",
                              "displayName":"myZAxis",
                              "maxSelectableValues":2
                           }
                        ],
                        "legendSettings":{
                           "background":"white",
                           "posX":50,
                           "posY":30,
                           "text":"blue",
                           "colors":[

                           ]
                        }
                     }
                  },
                  {
                     "label":"Waterfall Chart",
                     "icon":"icons:accessibility",
                     "element":"bar-chart",
                     "callBack":"initWaterfallChart",
                     "settings":{
                        "area":[
                           {
                              "input":"height",
                              "txt":"Height of the chart",
                              "uitype":"Number",
                              "selectedValue":"300",
                              "callBack":"chartHeightCb"
                           },
                           {
                              "input":"width",
                              "txt":"Width of the chart",
                              "uitype":"Number",
                              "selectedValue":"660"
                           },
                           {
                              "input":"marginTop",
                              "txt":"Top  margin",
                              "uitype":"Number",
                              "selectedValue":40
                           },
                           {
                              "input":"marginRight",
                              "txt":"Right margin",
                              "uitype":"Number",
                              "selectedValue":10
                           },
                           {
                              "input":"marginBottom",
                              "txt":"Bottom margin",
                              "uitype":"Number",
                              "selectedValue":20
                           },
                           {
                              "input":"marginLeft",
                              "txt":"Left margin",
                              "uitype":"Number",
                              "selectedValue":50
                           },
                           {
                              "input":"strokeWidth",
                              "txt":"Stroke Width",
                              "uitype":"Number",
                              "selectedValue":0,
                              "callBack":"strokeWidthCb"
                           },
                           {
                              "input":"xAxisRotation",
                              "txt":"Rotate X-Axis Tick",
                              "uitype":"sliderInput",
                              "selectedValue":0,
                              "min":-90,
                              "max":90,
                              "step":15,
                              "callBack":"xAxisRotationCb"
                           },
                           {
                              "input":"yAxisRotation",
                              "txt":"Rotate Y-Axis Tick",
                              "uitype":"sliderInput",
                              "selectedValue":0,
                              "min":-60,
                              "max":60,
                              "step":12,
                              "callBack":"yAxisRotationCb"
                           }
                        ],
                        "inputs":[
                           {
                              "input":"x",
                              "txt":"Pick Dimension",
                              "selectedValue":[
                                 0
                              ],
                              "scaleType":"",
                              "format":"",
                              "selectedObjs":[
                                 {
                                    "key":"a",
                                    "value":0,
                                    "type":"Number"
                                 }
                              ],
                              "uitype":"single-value",
                              "displayName":"myXAxis",
                              "maxSelectableValues":1
                           },
                           {
                              "input":"y",
                              "txt":"Pick Measures",
                              "selectedValue":[
                                 1
                              ],
                              "format":"",
                              "scaleType":"",
                              "selectedObjs":[
                                 {
                                    "key":"b",
                                    "value":1,
                                    "type":"Number"
                                 }
                              ],
                              "uitype":"multi-value",
                              "displayName":"myYAxis",
                              "maxSelectableValues":2
                           },
                           {
                              "input":"z",
                              "txt":"Pick Z",
                              "selectedValue":[

                              ],
                              "format":"",
                              "scaleType":"",
                              "selectedObjs":[

                              ],
                              "uitype":"multi-value",
                              "displayName":"myZAxis",
                              "maxSelectableValues":2
                           }
                        ],
                        "legendSettings":{
                           "background":"white",
                           "posX":50,
                           "posY":30,
                           "text":"blue",
                           "colors":[
                              {
                                 "color":"#FFC107",
                                 "label":"a"
                              }
                           ]
                        }
                     }
                  },
                  {
                     "label":"Difference",
                     "icon":"icons:rowing",
                     "element":"bar-chart",
                     "callBack":"initDiffrenceChart"
                  },
                  {
                     "label":"Pie Chart",
                     "icon":"icons:content-cut",
                     "element":"pie-chart",
                     "callBack":"setPieSettings"
                  },
                  {
                     "label":"Heat Map",
                     "icon":"icons:bug-report",
                     "element":"bar-chart",
                     "callBack":"setHeatMapSettings"
                  },
                  {
                     "label":"Area Chart",
                     "icon":"icons:dns",
                     "element":"area-chart",
                     "callBack":"setAreaSettings"
                  },
                  {
                     "label":"Sankey Chart",
                     "icon":"icons:check-circle",
                     "element":"sankey-chart",
                     "callBack":"setSankeySettings"
                  }
               ]
            }
         },
         "enabled":true,
         "editorMode":"ace/mode/scala"
      },
      "id":"20161116-114511_470035935",
      "paragraph":"%sql\nselect * from gmt\norder by a"
   },
   "ticket":"anonymous"
}
<web-socket id="socket" url="[[ ws ]]" json on-open="_onOpen" on-close="_onClose" on-message="handleResponse" on-error="_onError"></web-socket>

Zeppelin Log

0 个答案:

没有答案
相关问题