国内从 Docker Hub 拉取镜像有时会遇到困难,此时可以配置镜像加速器。
Dockerized 实践 https://github.com/y0ngb1n/dockerized
国内从 Docker Hub 拉取镜像有时会遇到困难,此时可以配置镜像加速器。
Dockerized 实践 https://github.com/y0ngb1n/dockerized
##服务代码 | |
```python | |
#!/usr/bin/env python2 | |
#coding=utf-8 | |
import tornado.ioloop | |
import tornado.web | |
from tornado.escape import json_encode |
/* BTrace Script Template */ | |
import com.sun.btrace.annotations.*; | |
import static com.sun.btrace.BTraceUtils.*; | |
import java.lang.reflect.Field; | |
@BTrace | |
public class TracingScript { | |
/* | |
* 获取方参数、返回值信息;获取方法调用时间 |
public class ArrayQueueSemaphore implements Queue { | |
private final Semaphore notFull = new Semaphore(10); | |
private final Semaphore notEmpty = new Semaphore(0); | |
private final ReentrantLock lock = new ReentrantLock(); | |
private final String[] connections = new String[10]; | |
int putIndex, takeIndex, count; | |
public void put(String e) throws InterruptedException { | |
notFull.acquire(); |
package com.github.melin.concurrnt.future; | |
import java.util.concurrent.CompletableFuture; | |
import java.util.concurrent.Executor; | |
import java.util.concurrent.Executors; | |
import java.util.concurrent.TimeUnit; | |
import java.util.function.BiFunction; | |
import java.util.function.Consumer; | |
import java.util.function.Function; | |
import java.util.function.Supplier; |
1. Send HTTP GET Request | |
String url = "http://www.google.com/search?q=httpClient"; | |
HttpClient client = HttpClientBuilder.create().build(); | |
HttpGet request = new HttpGet(url); | |
// add request header | |
request.addHeader("User-Agent", USER_AGENT); | |
HttpResponse response = client.execute(request); |
1、ByteBuf支持同时读写操作,包含writerIndex和readerIndex两个变量,如果readerIndex值超过writerIndex,将会抛出IndexOutOfBoundsException错误。 | |
2、ByteBuf支持head buffer(jvm堆中)和direct buffer,堆外分配buffer成本更高。 | |
3、使用ByteBuffer实例: | |
ByteBuf heapBuf = ...; | |
if (heapBuf.hasArray()) { #1 | |
byte[] array = heapBuf.array(); #2 | |
int offset = heapBuf.arrayOffset() + heapBuf.position(); #3 | |
int length = heapBuf.readableBytes(); #4 | |
YourImpl.method(array, offset, length); #5 | |
} |
ChannelInboundHandlerAdapter | |
@Override | |
public void channelRead(ChannelHandlerContext ctx, Object msg) { | |
System.out.println(ìServer received: ì + msg); | |
ctx.write(msg) #2 | |
} | |
@Override | |
public void channelReadComplete(ChannelHandlerContext ctx) { | |
ctx.writeAndFlush(Unpooled.EMPTY_BUFFER) | |
.addListener(ChannelFutureListener.CLOSE); #3 |
import java.io.*; | |
import java.util.*; | |
import sun.jvm.hotspot.memory.*; | |
import sun.jvm.hotspot.oops.*; | |
import sun.jvm.hotspot.debugger.*; | |
import sun.jvm.hotspot.runtime.*; | |
import sun.jvm.hotspot.tools.*; | |
import sun.jvm.hotspot.utilities.*; | |
public class DirectMemorySize extends Tool { |