es 乐观锁问题重现

package es;

import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import jodd.http.HttpRequest;
import jodd.http.HttpResponse;

public class Test {
	static ExecutorService pool = Executors.newFixedThreadPool(16);

	public static void main(String[] args) {

		for (int i = 0; i < 200; i++) {

			pool.submit(new Thread() {
				public void run() {
					for (int i = 0; i < 1; i++) {
						update();
					}

				};
			});

		}
	}
	
	public static void update() {
		HttpRequest httpRequest = HttpRequest
		// .post("http://127.0.0.1:9200/zzm/zzm/1");
		// .put("http://192.168.1.29:9200/zzm/zzm/1");
				.post("http://192.168.1.29:9200/zzm/zzm/1/_update");
		httpRequest.header("Content-Type",
				"application/x-www-form-urlencoded; charset=UTF-8");
		String str = "{\"script\": \"ctx._source.title = 'new conten"+UUID.randomUUID().toString()+"'\"}";
		httpRequest.bodyText(str);
		System.out.println("str=========="+str);
		HttpResponse response = httpRequest.send();
		System.out.println(response.bodyText());

	}

	public static void move() {
		HttpRequest httpRequest = HttpRequest
		// .post("http://127.0.0.1:9200/zzm/zzm/1");
		// .put("http://192.168.1.29:9200/zzm/zzm/1");
				.post("http://192.168.1.29:9200/zzm/zzm/1");
		httpRequest.header("Content-Type",
				"application/x-www-form-urlencoded; charset=UTF-8");
		httpRequest.bodyText("{\"title\":\"zzm" + UUID.randomUUID().toString()
				+ "\"}");
		HttpResponse response = httpRequest.send();
		System.out.println(response.bodyText());

	}

}

 

你可能感兴趣的:(es 乐观锁问题重现)