Slick 3.2 官方文档(http://slick.lightbend.com/doc/3.2.0/database.html)表示,Slick 可以配置为正常的,javax.sql.DataSource例如PGSimpleDataSource或PGPoolingDataSource:
val db = Database.forDataSource(dataSource: javax.sql.DataSource, Some(size: Int))
Run Code Online (Sandbox Code Playgroud)
我找不到Database要导入的对象。
该数据库单例对象甚至不存在于官方 ScalaDoc 中: http://slick.lightbend.com/doc/3.2.0/api/index.html
我在我的build.sbt. Database我是否缺少 slick-postgresql 绑定或文档中指定的缺少对象的其他依赖项?
"com.typesafe.slick" %% "slick" % "3.2.0"
"org.postgresql" % "postgresql" % "42.0.0"
Run Code Online (Sandbox Code Playgroud) 像这样的 Prometheus 规则文件:
groups:
- name: ./example.rules
rules:
- alert: ExampleAlert
expr: vector(1)
Run Code Online (Sandbox Code Playgroud)
Kubernetes prometheus-operator 需要一个额外的 yaml 配置数据层,如下所示:
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
creationTimestamp: null
labels:
prometheus: example
role: alert-rules
name: prometheus-example-rules
spec:
groups:
- name: ./example.rules
rules:
- alert: ExampleAlert
expr: vector(1)
Run Code Online (Sandbox Code Playgroud)
对于使用前一种原始 Prometheus 规则格式的文件,我可以使用 Prometheuspromtool来运行单元测试。(见下方链接3)
对于使用后一种扩展 PrometheusRule 格式的文件,我可以使用kubectl apply -f prometheus_rule_file.yaml将规则加载到我的 prometheus-operator 安装中。
我想以这些文件格式之一编写和维护规则,并且能够在 promtool 的单元测试系统中使用相同的规则文件,并将相同的规则加载到 prometheus-operator 安装中。我看不出有什么简单的方法可以做到这一点。
有没有办法可以使用原始 Prometheus 规则格式制定规则并将其加载到 prometheus-operator PrometheusRule 中,而无需维护单独的冗余 yaml 文件,也无需编写自定义工具来转换它?
我按照说明使用Scala 2.11构建Spark:
mvn -Dscala-2.11 -DskipTests clean package
Run Code Online (Sandbox Code Playgroud)
然后我按照说明启动:
./sbin/start-master.sh
Run Code Online (Sandbox Code Playgroud)
它在日志文件中有两行失败:
Failed to find Spark assembly in /etc/spark-1.2.1/assembly/target/scala-2.10
You need to build Spark before running this program.
Run Code Online (Sandbox Code Playgroud)
显然,它正在寻找scala-2.10版本,但我做了一个scala-2.11版本.我尝试了明显的-Dscala-2.11标志,但这没有改变任何东西.文档没有提到有关如何使用scala 2.11在独立模式下运行的任何内容.
提前致谢!
我想为可减少类型创建一个类型类
Ord.subtract功能.UTCTime,Double和Int(或任选的任何Num类型)有一种Delta类型可能与源值类型不同.例如,值类型为UTCTime,delta类型为NominalDiffTime.对于Int,Doubledelta类型与值类型相同.
diffUTCTime :: UTCTime - > UTCTime - > NominalDiffTime
delta类型应该实现Num.
这根本不起作用,但希望能传达我想要做的事情
class Ord a => Subtractable a where
-- The type alias for the delta type
type Num b => b
-- The subtract function
subtractValues :: a -> a -> b
Run Code Online (Sandbox Code Playgroud) 我正在Amazon EMR 5.0的Spark 2.0上尝试一个超级简单的测试程序:
from pyspark.sql.types import Row
from pyspark.sql.types import *
import pyspark.sql.functions as spark_functions
schema = StructType([
StructField("cola", StringType()),
StructField("colb", IntegerType()),
])
rows = [
Row("alpha", 1),
Row("beta", 2),
Row("gamma", 3),
Row("delta", 4)
]
data_frame = spark.createDataFrame(rows, schema)
print("count={}".format(data_frame.count()))
data_frame.write.save("s3a://test3/test_data.parquet", mode="overwrite")
print("done")
Run Code Online (Sandbox Code Playgroud)
结果是:
count=4
Py4JJavaError: An error occurred while calling o85.save.
: org.apache.spark.SparkException: Job aborted.
at org.apache.spark.sql.execution.datasources.InsertIntoHadoopFsRelationCommand$$anonfun$run$1.apply$mcV$sp(InsertIntoHadoopFsRelationCommand.scala:149)
at org.apache.spark.sql.execution.datasources.InsertIntoHadoopFsRelationCommand$$anonfun$run$1.apply(InsertIntoHadoopFsRelationCommand.scala:115)
at org.apache.spark.sql.execution.datasources.InsertIntoHadoopFsRelationCommand$$anonfun$run$1.apply(InsertIntoHadoopFsRelationCommand.scala:115)
at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:57)
at org.apache.spark.sql.execution.datasources.InsertIntoHadoopFsRelationCommand.run(InsertIntoHadoopFsRelationCommand.scala:115)
at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult$lzycompute(commands.scala:60)
at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult(commands.scala:58)
at org.apache.spark.sql.execution.command.ExecutedCommandExec.doExecute(commands.scala:74)
at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:115)
at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:115)
at org.apache.spark.sql.execution.SparkPlan$$anonfun$executeQuery$1.apply(SparkPlan.scala:136)
at …Run Code Online (Sandbox Code Playgroud) 就像是:
def cast[T](o: Any): Option[T] = o match {
case v: T => Some(v)
case _ => None
}
Run Code Online (Sandbox Code Playgroud)
或者:
def cast[T](c: Class[T], o: Any): Option[T] = o match {
case v: T => Some(v)
case _ => None
}
Run Code Online (Sandbox Code Playgroud)
这是一个好主意吗?是否有等效的标准库?
为什么会出现以下 Scala 编译器警告以及如何解决:
Warning:(7, 13) abstract type pattern T is unchecked since it is eliminated by erasure
case v: T => Some(v)
Run Code Online (Sandbox Code Playgroud) 我有一个简单的logstash grok过滤器:
filter {
grok {
match => { "message" => "^%{TIMESTAMP_ISO8601:timestamp} %{NOTSPACE:name} %{WORD:level} %{SPACE} %{GREEDYDATA:message}$" }
overwrite => [ "message" ]
}
}
Run Code Online (Sandbox Code Playgroud)
这可行,它解析我的日志,但根据Kibana,时间戳值以数据类型输出string.
logstash @timestamp字段具有数据类型date.
grok文档说您可以指定数据类型转换,但只支持int和float:
如果您希望转换语义的数据类型,例如将字符串更改为整数,则使用目标数据类型将其后缀.例如%{NUMBER:num:int},它将num语义从字符串转换为整数.目前唯一支持的转换是int和float.
这表明我应该把它留作字符串,但是,如果索引支持datetime值,为什么你不希望它正确存储并可以作为日期时间进行排序?
我有一个 Homebrew 安装了 kubernetes-cli 1.12.0 和 minikube 0.30.0:
~ ls -l $(which kubectl)
/usr/local/bin/kubectl -> ../Cellar/kubernetes-cli/1.12.0/bin/kubectl
~ ls -l $(which minikube)
/usr/local/bin/minikube -> /usr/local/Caskroom/minikube/0.30.0/minikube-darwin-amd64
~ minikube delete
Deleting local Kubernetes cluster...
Machine deleted.
~ rm -rf ~/.kube ~/.minikube
~ minikube start --memory 8000 --kubernetes-version 1.12.0
Starting local Kubernetes 1.12.0 cluster...
Starting VM...
Downloading Minikube ISO
170.78 MB / 170.78 MB [============================================] 100.00% 0s
Getting VM IP address...
Moving files into cluster...
E1022 10:08:41.271328 44100 start.go:254] Error updating cluster: generating kubeadm …Run Code Online (Sandbox Code Playgroud) 如果我启动一个全新的、空的 minikube 和helm install最新stable/prometheus-operator的严格默认设置,我会看到四个活动的 Prometheus 警报。
在这个超级简化的场景中,我有一个干净的新 minikube,除了 Prometheus 之外什么都没有运行,应该没有问题,也没有警报。这些警报是假的还是坏了?我的设置有问题吗?或者我应该提交错误报告并暂时禁用这些警报?
以下是我的基本设置步骤:
minikube delete
# Any lower memory/cpu settings will experience problems
minikube start --memory 10240 --cpus 4 --kubernetes-version v1.12.2
eval $(minikube docker-env)
helm init
helm repo update
# wait a minute for Helm Tiller to start up.
helm install --name my-prom stable/prometheus-operator
Run Code Online (Sandbox Code Playgroud)
等待几分钟让一切启动,然后在 Prometheus 服务器和 Grafana 上运行端口转发:
kubectl port-forward service/my-prom-prometheus-operato-prometheus 9090:9090
kubectl port-forward service/my-prom-grafana 8080:80
Run Code Online (Sandbox Code Playgroud)
然后去http://localhost:9090/alerts看看:
DeadMansSwitch (1 active)
KubeControllerManagerDown (1 active)
KubeSchedulerDown (1 …Run Code Online (Sandbox Code Playgroud) 在 Python 2.7 中,我可以这样做,将参数传递给 sql 命令,如下所示:
cursor.execute("select * from my_table where id = %s", [2])
Run Code Online (Sandbox Code Playgroud)
我无法像这样获得等效的数组:
cursor.execute("select * from my_table where id in %s", [[10,2]])
Run Code Online (Sandbox Code Playgroud)
显然,我只能进行字符串格式化,但如果可能的话,我想做一个适当的参数。如果重要的话,我正在使用 postgresql 数据库。
scala ×3
apache-spark ×2
kubernetes ×2
minikube ×2
postgresql ×2
prometheus ×2
casting ×1
haskell ×1
logstash ×1
python ×1
python-2.7 ×1
scala-2.11 ×1
slick ×1
typeclass ×1