我对这两个描述非常困惑:
这是我的问题:
我知道Java中的每个对象都有一个锁,但"监视器锁"是什么意思?是否与oject的锁相同?
为什么通知方法需要放弃显示器锁定?
如果我尝试使用以下代码使对象等待:
class simpleTask extends Thread
{
int waitingTime;
public simpleTask(int waitingTime)
{
this.waitingTime = waitingTime;
}
public void run()
{
synchronized(this) // this is a reference of current object
{
try {
this.wait(waitingTime);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Run Code Online (Sandbox Code Playgroud)与上面的第一个描述一样,是指当前对象被synchronized关键字阻塞,然后wait方法释放锁?
我正在努力如何正确使用分区键机制.我的逻辑是将分区号设置为3,然后创建三个分区键为"0","1","2",然后使用分区键创建三个KeyedMessage,如
在此之后,创建一个生成器实例以发送所有KeyedMessage.
我希望每个KeyedMessage都应该根据不同的分区键进入不同的分区,这意味着
我正在使用Kafka-web-console来观察主题状态,但结果并不像我期望的那样.KeyedMessage仍然随机进入分区,有时候两个KeyedMessage将进入同一个分区,即使它们有不同的分区键.
为了使我的问题更清楚,我想发布一些我现有的Scala代码,并且我正在使用Kafka 0.8.2-beta和Scala 2.10.4.
这是生产者代码,我没有使用自定义partitioner.class:
val props = new Properties()
val codec = if(compress) DefaultCompressionCodec.codec else NoCompressionCodec.codec
props.put("compression.codec", codec.toString)
props.put("producer.type", if(synchronously) "sync" else "async")
props.put("metadata.broker.list", brokerList)
props.put("batch.num.messages", batchSize.toString)
props.put("message.send.max.retries", messageSendMaxRetries.toString)
props.put("request.required.acks",requestRequiredAcks.toString)
props.put("client.id",clientId.toString)
val producer = new Producer[AnyRef, AnyRef](new ProducerConfig(props))
def kafkaMesssage(message: Array[Byte], partition: Array[Byte]): KeyedMessage[AnyRef, AnyRef] = {
if (partition == null) {
new KeyedMessage(topic,message)
} else {
new KeyedMessage(topic,partition,message)
}
}
def send(message: String, partition: String …Run Code Online (Sandbox Code Playgroud) 当图像被推送到注册表V2时,图像ID是否也会被推送到注册表中?是否可以从V2注册表获取某个存储库的图像ID?
我跑:
$ docker run --rm -ti -p 9200:9200 -p 9300:9300 elasticsearch
Run Code Online (Sandbox Code Playgroud)
但我无法启动elasticsearch 5.0,这里的日志:
Unable to find image 'elasticsearch:latest' locally
latest: Pulling from library/elasticsearch
43c265008fae: Already exists
af36d2c7a148: Already exists
2b7b4d10e1c1: Already exists
9f7579daddb2: Already exists
a985511f2468: Already exists
6c2b485fcc3e: Already exists
00b73c83b440: Already exists
a38975861823: Pull complete
b9d0b4aaf934: Pull complete
f5f25bb3de04: Pull complete
93426e1e8953: Pull complete
590c2ab9b639: Pull complete
31bf48850601: Pull complete
21aad7ce70fa: Pull complete
Digest: sha256:29205bca045c8d083f777dfc453f4f1ff3d2c08ea4f529f88795166c58e5607e
Status: Downloaded newer image for elasticsearch:latest
[2016-10-31T20:56:22,023][INFO ][o.e.n.Node ] [] initializing ...
[2016-10-31T20:56:22,129][INFO …Run Code Online (Sandbox Code Playgroud) 有一个
String temp = "M0-1"
Run Code Online (Sandbox Code Playgroud)
如何将此String转换为String []?
如果输出新的String数组,结果应为:
String[] newStringArray;
newStringArray[0] = M;
newStringArray[1] = 0;
newStringArray[2] = -1;
Run Code Online (Sandbox Code Playgroud)
新String数组的最后一个元素应该是"-1",这意味着"-1"将被视为一个整体,而不是" - "和"1".
我试图使用String.split("")解析这个字符串,但只得到一个这样的String数组:
String[] newStringArray;
newStringArray[0] = M;
newStringArray[1] = 0;
newStringArray[2] = -;
newStringArray[3] = 1;
Run Code Online (Sandbox Code Playgroud)
更新:字符串56应为[5,6],-10应为[-1,0]
docker ×2
java ×2
apache-kafka ×1
arrays ×1
docker-image ×1
locking ×1
notify ×1
scala ×1
wait ×1