我正在使用Jedis连接到AWS中的Redis实例/集群,但是我一直收到此错误,这是代码,我在SO上进行了广泛搜索,发现最接近的是:属性文件中的字符串主机名:Java
我尝试了两种方式,都没有为我工作。所以请帮忙。
这是我的Java代码:
public static void main(String[] args) {
AWSCredentials credentials = null;
try {
credentials = new ProfileCredentialsProvider("default").getCredentials();
} catch (Exception e) {
throw new AmazonClientException("Cannot load the credentials from the credential profiles file. "
+ "Please make sure that your credentials file is at the correct "
+ "location (/Users/USERNAME/.aws/credentials), and is in valid format.", e);
}
AmazonElastiCacheClient client = new AmazonElastiCacheClient(credentials);
client.setRegion(Region.getRegion(Regions.AP_NORTHEAST_2));
DescribeCacheClustersRequest dccRequest = new DescribeCacheClustersRequest();
dccRequest.setShowCacheNodeInfo(true);
DescribeCacheClustersResult clusterResult = client.describeCacheClusters(dccRequest);
List<CacheCluster> cacheClusters = clusterResult.getCacheClusters(); …Run Code Online (Sandbox Code Playgroud) 有不明白的地方,请大家帮忙。
System.out.println("\n" + Arrays.toString(buffer) + "\n");
System.out.println("buffer.length = " + buffer.length + "\nnew ByteArrayInputStream(buffer).available() is: " + new ByteArrayInputStream(buffer).available());
ObjectInput input = new ObjectInputStream(new ByteArrayInputStream(buffer));
System.out.println("input.available(): " + input.available());
Run Code Online (Sandbox Code Playgroud)
它的输出如下:
[-84, -19, 0, 5]
buffer.length = 4
new ByteArrayInputStream(buffer).available() is: 4
input.available(): 0
Run Code Online (Sandbox Code Playgroud)
我很困惑为什么一个包含 4 个有效字节的字节数组在放入 ObjectInputStream 后变为零。
我尝试过的事情:
所以,我不知道为什么会发生这种情况。
请帮忙,非常感谢!
我需要将这个给定的日期格式转换2019-10-22 00:00:00为:2019-10-22T00:00:00.000Z
我知道这可以通过以下方式在某些数据库中完成:
在 AWS Redshift 中,您可以使用以下方法实现此目的:
TO_DATE('{RUN_DATE_YYYY/MM/DD}', 'YYYY/MM/DD') || 'T00:00:00.000Z' AS VERSION_TIME
Run Code Online (Sandbox Code Playgroud)
但是我的平台是 Spark SQL,所以以上两个都不适合我,我能得到的最好的就是使用这个:
concat(d2.VERSION_TIME, 'T00:00:00.000Z') as VERSION_TIME
Run Code Online (Sandbox Code Playgroud)
这有点hacky,但仍然不完全正确,有了这个,我得到了这个日期格式:2019-10-25 00:00:00T00:00:00.000Z,但是 00:00:00字符串中间的这部分是多余的,我不能把它留在那里。
任何人在这里有任何见解将不胜感激!
我想在我的 Macbook 上运行一些代码,通过堡垒主机访问 VPC 中的一个 Elasticsearch 集群。
这是我的 ssh 隧道命令:
ssh -i ~/Downloads/keypairs/20210402-02.pem ubuntu@ec2-123-456.us-west-2.compute.amazonaws.com -N -L 9200:https://vpc-123-es-domain-20210406-3abc123.us-west-2.es.amazonaws.com:443
Run Code Online (Sandbox Code Playgroud)
但是,这给了我以下错误:
bind [0.0.35.240]:443: Can't assign requested address
channel_setup_fwd_listener_tcpip: cannot listen to port: 443
Could not request local forwarding.
Run Code Online (Sandbox Code Playgroud)
添加-v了以下详细信息:
OpenSSH_8.1p1, LibreSSL 2.7.3
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 47: Applying options for *
debug1: Connecting to ec2-123-456.us-west-2.compute.amazonaws.com port 22.
debug1: Connection established.
debug1: identity file /Users/fisher/Downloads/keypairs/20210402-02.pem type -1
debug1: identity file /Users/fisher/Downloads/keypairs/20210402-02.pem-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.1 …Run Code Online (Sandbox Code Playgroud) 我有一个这样的字典:key是一个字符串,value是一个字符串列表
my_dict = {
'key1': [value11, value12, value13],
'key2': [value21, value22, value23],
'key3': [value31, value32, value33],
'key4': [value41, value42, value43]
}
Run Code Online (Sandbox Code Playgroud)
例如
dict_0 = {
'key1' : [lv, 2, abc],
'key2' : [ab, 4, abc],
'key3' : [xj, 1, abc],
'key4' : [om, 3, abc],
}
Run Code Online (Sandbox Code Playgroud)
我想根据值列表中的第二个值进行排序,因此,它应该是这样的:
dict_0 = {
'key3' : [xj, 1, abc],
'key1' : [lv, 2, abc],
'key4' : [om, 3, abc],
'key2' : [ab, 4, abc],
}
Run Code Online (Sandbox Code Playgroud)
我想通过值列表中的值之一来对此dict进行排序,即值*2,我该怎么做?我在网站上进行了大量搜索,但没有找到类似的情况.
谢谢.
我有一个像这样的字符串:
"[{1000, 500, 1}, {1001, 501, 1}, {1002, 501, 2}]"
(这不仅仅是数字,也可能是人物.)
我怎样才能将它分成三个部分:
{1000, 500, 1}
{1001, 501, 1}
{1002, 501, 2}
第二步:将每个新子字符串拆分为自己的字段,例如{1000, 500, 1},进入1000,500 1.
我试过的事情:
,它来拆分它们,但显然,它的格式不是很好,中间有空间.看起来需要一些预格式化吗?有什么想法吗?非常感谢!
一个非常简单的问题:
我尝试使用 bash 脚本提交 Spark 作业。但不知怎的,它一直抱怨找不到spark-submit命令。但是当我复制命令并直接在终端中运行时,它运行良好。
我的 shell 是 Fish shell,这是我的 Fish shell 配置中的内容~/.config/fish/config.fish::
alias spark-submit='/Users/MY_NAME/Downloads/spark-2.0.2-bin-hadoop2.7/bin/spark-submit'
这是我的 bash 脚本:
#!/usr/bin/env bash
SUBMIT_COMMAND="HADOOP_USER_NAME=hdfs spark-submit \
--master $MASTER \
--deploy-mode client \
--driver-memory $DRIVER_MEMORY \
--executor-memory $EXECUTOR_MEMORY \
--num-executors $NUM_EXECUTORS \
--executor-cores $EXECUTOR_CORES \
--conf spark.shuffle.compress=true \
--conf spark.network.timeout=2000s \
$DEBUG_PARAM \
--class com.fisher.coder.OfflineIndexer \
--verbose \
$JAR_PATH \
--local $LOCAL \
$SOLR_HOME \
--solrconfig 'resource:solrhome/' \
$ZK_QUORUM_PARAM \
--source $SOURCE \
--limit $LIMIT \
--sample $SAMPLE \ …Run Code Online (Sandbox Code Playgroud) java ×3
amazon-ec2 ×1
apache-spark ×1
bash ×1
date-format ×1
dictionary ×1
fish ×1
format ×1
io ×1
jedis ×1
macos ×1
pyspark ×1
python ×1
redis ×1
regex ×1
shell ×1
sql ×1
ssh ×1
ssh-tunnel ×1