小编Ger*_*Gum的帖子

Spark多个上下文

简而言之:

EC2集群:1个主3个从属

Spark版本:1.3.1

我希望使用选项spark.driver.allowMultipleContexts,一个上下文本地(仅限主)和一个集群(主服务器和从服务器).

我得到这个stacktrace错误(第29行是我调用初始化第二个sparkcontext的对象):

fr.entry.Main.main(Main.scala)
   at org.apache.spark.SparkContext$$anonfun$assertNoOtherContextIsRunning$1$$anonfun$apply$10.apply(SparkContext.scala:1812)
   at org.apache.spark.SparkContext$$anonfun$assertNoOtherContextIsRunning$1$$anonfun$apply$10.apply(SparkContext.scala:1808)
   at scala.Option.foreach(Option.scala:236)
   at org.apache.spark.SparkContext$$anonfun$assertNoOtherContextIsRunning$1.apply(SparkContext.scala:1808)
   at org.apache.spark.SparkContext$$anonfun$assertNoOtherContextIsRunning$1.apply(SparkContext.scala:1795)
   at scala.Option.foreach(Option.scala:236)
   at org.apache.spark.SparkContext$.assertNoOtherContextIsRunning(SparkContext.scala:1795)
   at org.apache.spark.SparkContext$.setActiveContext(SparkContext.scala:1847)
   at org.apache.spark.SparkContext.<init>(SparkContext.scala:1754)
   at fr.entry.cluster$.<init>(Main.scala:79)
   at fr.entry.cluster$.<clinit>(Main.scala)
   at fr.entry.Main$delayedInit$body.apply(Main.scala:29)
   at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
   at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
   at scala.App$$anonfun$main$1.apply(App.scala:71)
   at scala.App$$anonfun$main$1.apply(App.scala:71)
   at scala.collection.immutable.List.foreach(List.scala:318)
   at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:32)
   at scala.App$class.main(App.scala:71)
   at fr.entry.Main$.main(Main.scala:14)
   at fr.entry.Main.main(Main.scala)
15/09/28 15:33:30 INFO AppClient$ClientActor: Executor updated: app-  20150928153330-0036/2 is now LOADING
15/09/28 15:33:30 INFO AppClient$ClientActor: Executor updated: app-    20150928153330-0036/0 is now RUNNING
15/09/28 15:33:30 INFO AppClient$ClientActor: Executor updated: app-20150928153330-0036/1 …
Run Code Online (Sandbox Code Playgroud)

scala apache-spark

10
推荐指数
1
解决办法
2万
查看次数

如何知道/获取hashmap的容量?

我很好奇,我在文档中读到:

容量是哈希表中的桶数...负载因子是在自动增加容量之前允许哈希表获取的完整程度的度量.当哈希表中的条目数超过加载因子和当前容量的乘积时,哈希表将被重新哈希(即,重建内部数据结构),以便哈希表具有大约两倍的桶数.

有没有办法在t时刻知道hashmap的容量(桶的数量)?

java hashmap

8
推荐指数
2
解决办法
4494
查看次数

从IDE运行时Flink webui

我想在网上看到我的工作.

我使用createLocalEnvironmentWithWebUI,代码在IDE中运行良好,但无法在http:// localhost:8081 /#/ overview中看到我的工作

  val conf: Configuration = new Configuration()
  import org.apache.flink.configuration.ConfigConstants
  conf.setBoolean(ConfigConstants.LOCAL_START_WEBSERVER, true)
  val env =  StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(conf)
  env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime)


  val rides = env.addSource(
    new TaxiRideSource("nycTaxiRides.gz", 1,100))//60, 600))

  val filteredRides = rides
    .filter(r => GeoUtils.isInNYC(r.startLon, r.startLat) && GeoUtils.isInNYC(r.endLon, r.endLat))
    .map(r => (r.passengerCnt, 1))
    .keyBy(_._1)
    .window(TumblingTimeWindows.of(Time.seconds(5)))
    .sum(1)
    .map(r => (r._1.toString+"test", r._2))

  filteredRides.print()
  env.execute("Taxi Ride Cleansing")
Run Code Online (Sandbox Code Playgroud)

我需要设置其他东西吗?

apache-flink flink-streaming

8
推荐指数
2
解决办法
2486
查看次数

选择第一个单词多行vim

我想复制多行的第一个单词.

代码示例:

apiKey := fmt.Sprintf("&apiKey=%s", args.ApiKey)
maxCount := fmt.Sprintf("&maxCount=%d", args.MaxCount)
id := fmt.Sprintf("&id=%s", args.Id)
userid := fmt.Sprintf("&userid=%s", args.Userid)
requestFields := fmt.Sprintf("&requestFields=%s", args.RequestFields)
Run Code Online (Sandbox Code Playgroud)

我想在我的剪贴板中有这个:

apiKey
maxCount
id
userid
requestFields
Run Code Online (Sandbox Code Playgroud)

我尝试使用ctrl-v和e之后,但它在图像上复制: 在此输入图像描述

vim

7
推荐指数
1
解决办法
1653
查看次数

wordcount示例中的Spark指标

我阅读了Spark 网站上的Metrics部分.我希望在wordcount示例上尝试它,我无法使它工作.

spark/conf/metrics.properties:

# Enable CsvSink for all instances
*.sink.csv.class=org.apache.spark.metrics.sink.CsvSink

# Polling period for CsvSink
*.sink.csv.period=1

*.sink.csv.unit=seconds

# Polling directory for CsvSink
*.sink.csv.directory=/home/spark/Documents/test/

# Worker instance overlap polling period
worker.sink.csv.period=1

worker.sink.csv.unit=seconds

# Enable jvm source for instance master, worker, driver and executor
master.source.jvm.class=org.apache.spark.metrics.source.JvmSource

worker.source.jvm.class=org.apache.spark.metrics.source.JvmSource

driver.source.jvm.class=org.apache.spark.metrics.source.JvmSource

executor.source.jvm.class=org.apache.spark.metrics.source.JvmSource
Run Code Online (Sandbox Code Playgroud)

我在本地运行我的应用程序,如文档中所示:

$SPARK_HOME/bin/spark-submit   --class "SimpleApp"   --master local[4]   target/scala-2.10/simple-project_2.10-1.0.jar
Run Code Online (Sandbox Code Playgroud)

我检查了/ home/spark/Documents/test /它是空的.

我错过了什么?


贝壳:

$SPARK_HOME/bin/spark-submit   --class "SimpleApp"   --master local[4]  --conf   spark.metrics.conf=/home/spark/development/spark/conf/metrics.properties  target/scala-2.10/simple-project_2.10-1.0.jar
Spark assembly has been built with Hive, including Datanucleus jars on classpath
Using …
Run Code Online (Sandbox Code Playgroud)

metrics apache-spark

6
推荐指数
1
解决办法
4888
查看次数

返回HttpResponse到字符串长度0

我正在尝试在Android APP中的服务器上发出HTTPGet请求,但是当我更改字符串中的httpresponse时,字符串为0长度.

DefaultHttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet("http://"+server+path+"?assets="+URLEncoder.encode(query, "US-ASCII")+"&lt="+localTime+"&to="+timeOffset);
HttpResponse response = httpclient.execute(httpget);
System.out.println("Status"+ response.getStatusLine());
System.out.println("Length "+org.apache.http.util.EntityUtils.toString(response.getEntity()).length());
return org.apache.http.util.EntityUtils.toString(response.getEntity());
Run Code Online (Sandbox Code Playgroud)

Catlog:

I/System.out(22344): StatusHTTP/1.1 200 OK
I/System.out(21737): Length 0
Run Code Online (Sandbox Code Playgroud)

uri很好,当我在浏览器中复制/浏览它时,我得到如下结果:

{"ads":[{"i"...],"pxs":{}}
Run Code Online (Sandbox Code Playgroud)

有谁知道为什么我的字符串是空的?

Udpate 1:

    long localTime = System.currentTimeMillis();
    Date date = new Date();
    @SuppressWarnings("deprecation")
    int timeOffset = date.getTimezoneOffset ();
Run Code Online (Sandbox Code Playgroud)

更新2:

我添加了这一行:

httpget.setHeader("User-Agent", "Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)");
Run Code Online (Sandbox Code Playgroud)

现在我有这个错误:

目录下载

 E/AndroidRuntime(23584): FATAL EXCEPTION: AsyncTask #2
 E/AndroidRuntime(23584): java.lang.RuntimeException: An error occured while executing doInBackground()
 E/AndroidRuntime(23584):   at …
Run Code Online (Sandbox Code Playgroud)

java android

5
推荐指数
1
解决办法
1057
查看次数

HBase在哪个版本中集成了spark API?

我阅读了spark和hbase的文档:

http://hbase.apache.org/book.html#spark

我可以看到HBase的最后一个稳定版本是1.1.2,但我也看到apidocs版本为2.0.0-SNAPSHOT,并且sparkapidoc是空的.

我很困惑,为什么apidocs和HBase版本不匹配?

我的目标是使用Spark和HBase(bulkGet,bulkPut..etc).我如何知道这些功能已经在哪个HBase版本中实现?

如果有人对此有补充文件,那就太棒了.

我在hbase-0.98.13-hadoop1上.

hbase apache-spark

5
推荐指数
1
解决办法
409
查看次数

GRPC Python - 处理套接字错误的正确方法是什么?

错误 :

Rendezvous of RPC that terminated with: status = StatusCode.UNAVAILABLE details = "Socket closed" debug_error_string = "{"created":"@1576780304.349820911","description":"Error received from peer ipv4:104.155.6.79:443","file":"src/core/lib/surface/call.cc","file_line":1046,"grpc_message":"Socket closed","grpc_status":14}
Run Code Online (Sandbox Code Playgroud)

该错误的文档是这样说的The service is currently unavailable. This is most likely a transient condition, which can be corrected by retrying with a backoff.

我发现可用的退避GRPC ARGS是:

grpc.initial_reconnect_backoff_ms
grpc.max_reconnect_backoff_ms
grpc.min_reconnect_backoff_ms
Run Code Online (Sandbox Code Playgroud)

这些参数似乎默认具有这些值

#define GRPC_SUBCHANNEL_INITIAL_CONNECT_BACKOFF_SECONDS 1
#define GRPC_SUBCHANNEL_RECONNECT_MIN_TIMEOUT_SECONDS 20
#define GRPC_SUBCHANNEL_RECONNECT_MAX_BACKOFF_SECONDS 120
Run Code Online (Sandbox Code Playgroud)

你怎么知道退避会重试多少次?它是否链接到“grpc.enable_retries”?因为文档提到“透明重试”,我不确定它是否与退避选项相关。

处理代码 14 错误的正确方法是什么?

sockets grpc-python

5
推荐指数
0
解决办法
1489
查看次数

仅在一个活动上删除/隐藏searchView

我的项目中有3个活动,我想仅在一个活动中删除/隐藏操作栏中的searchView.

我试过searchView.setVisibility(View.GONE); 但仍然有可点击的图标.

main_menu.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >

<item android:id="@+id/menu_search"
      android:title="@string/menu_search"
      android:icon="@drawable/ic_menu_search"
      android:showAsAction="ifRoom|collapseActionView"
      android:actionViewClass="android.widget.SearchView" />
<item
    android:id="@+id/item_clear_memory_cache"
    android:title="@string/menu_item_clear_memory_cache"/>

<item
    android:id="@+id/item_clear_disc_cache"
    android:title="@string/menu_item_clear_disc_cache"/>

</menu>
Run Code Online (Sandbox Code Playgroud)

java android

4
推荐指数
2
解决办法
5588
查看次数

hiveQL if语句在一行重新组合

查询:

select IF(type='view', count(*), 0), IF(type='click', count(*), 0)
from ad_events
where year=2013 and month=01 and day=18 and (hour=01 or hour=02)
group by type
Run Code Online (Sandbox Code Playgroud)

结果:

      _c0       _c1
0      0         0
1      0         0
2      0       1368
3      0         0
4      0         0
5      0         0
6      0         0
7      0         0
8   277917       0
9      0         0
Run Code Online (Sandbox Code Playgroud)

反正有没有像这样的结果?:

      _c0       _c1
0    277917     1368
Run Code Online (Sandbox Code Playgroud)

hive hiveql

3
推荐指数
1
解决办法
2万
查看次数

如果成功,登录页面重定向新页面

我的应用程序使用 Mithril.js 和 Play Framework。

我想知道是否有一种(好的)方法可以在秘银和游戏之间划分我的应用程序。我想让 play 呈现一个 login.html,这个 login.html 将只包含我的 mithril.js 组件(login.js)的导入。如果登录成功,我想将我的应用程序重定向到另一个 html 页面。此页面将包含我所有秘银组件的所有导入。

所以我的应用程序在播放框架方面只有两个 html 页面,一个只导入一个秘银组件,另一个导入所有其他组件(仅在检查凭据时)。

  1. 播放路由器:

    GET / 控制器.Index.index

  2. 播放控制器:

    def index = Action { Ok(views.html.login()) }

  3. 登录.html

    <!DOCTYPE html> 
    <html lang="en">
    <head>
        <title>IHM</title>
         StylesSheet import..
    </head>
    <body id="app" class="body">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/mithril/0.2.2-rc.1/mithril.min.js"></script> 
    <script src="@routes.Assets.versioned("javascripts/claravista/login.js")" type="text/javascript"></script>
    
        <script type="text/javascript">
            m.route.mode = "pathname";
    
            m.route(document.getElementById('app'), "/", {
    
                "/": login,
    
            });
    
    
        </script>
    </body>
    
    Run Code Online (Sandbox Code Playgroud)
  4. Mithril 询问播放检查凭据(在组件登录中)

    m.request({method: "PUT", url: "/check-user", data : login.user }).then(returnCall);

  5. Case Credentials false : 再问一次(我已经做了这部分)

  6. Case Credentials true:重定向到另一个 html …

javascript scala playframework mithril.js

3
推荐指数
1
解决办法
2149
查看次数