Varnish Version 3有一些用于不同操作的对象.
例如,当必须从后端检索数据时使用pass.并且当它在缓存中发现请求内容时使用命中.
但我无法理解命中传球的用法.当清漆使用它?我没有在网上找到任何有用的材料让我清楚.
我想让Varnish记录请求.我找到了命令varnishlog -a -w /var/log/varnish.log,但它没有记录任何内容.
然后我发现Varnish默认不写入日志.但是,我无法找到日志记录的配置选项.
我们知道,String().intern()如果字符串池中尚不存在,则在字符串池中添加字符串值.如果存在,则返回该值/对象的引用.
String str = "Cat"; // creates new object in string pool with same character sequence.
String st1 = "Cat"; // has same reference of object in pool, just created in case of 'str'
str == str1 //that's returns true
String test = new String("dog");
test.intern();// what this line of code do behind the scene
Run Code Online (Sandbox Code Playgroud)
我需要知道,当我打电话给test.intern()这个实习方法会做什么?
在字符串池中添加带有不同引用的"dog"或在字符串池中添加test对象引用(我认为,情况并非如此)?
我试过这个
String test1 = "dog";
test == test1 // returns false
Run Code Online (Sandbox Code Playgroud)
我只是想确保,当我调用test.intern()它时,在String池中创建具有相同值的新对象?现在我有两个值为"dog"的对象.一个直接存在于堆中,另一个存在于String池中?
我们可以像这样创建lambda函数:
Function<Integer, String> getLambda = (a) -> new String("given value is "a);
Run Code Online (Sandbox Code Playgroud)
我有一个场景,我需要在参数中取2个值.如何使用Function实现这一目标?
例:
getLamda(10,20); // I know this line will give error. How can I acheive this?
Run Code Online (Sandbox Code Playgroud) 我很好奇如何删除字符串池中的值?
假设:
String a = "ABC"; // has a reference of string-pool
String b = new String("ABC"); // has a heap reference
b = null;
a = null;
Run Code Online (Sandbox Code Playgroud)
在GC的情况下,来自堆的"ABC"被收集但"ABC"仍然在池中(因为它在permGen和GC中不会影响它).
如果我们继续添加如下值:
String c = "ABC"; // pointing to 'ABC' in the pool.
for(int i=0; i< 10000; i++) {
c = ""+i;
// each iteration adds a new value in the pool. Previous values don't have a pointer.
}
Run Code Online (Sandbox Code Playgroud)
我想知道的是:
由于新创建的对象被分配给新一代.是否有可能将新创建的对象直接分配给旧的或终身的一代?如果是,那么在哪个基地?
我正在使用quickfixj。我有一条自定义消息,例如“ EndTrade”,当收到该消息时,我想结束修复会话吗?我怎样才能做到这一点?我还没有找到任何办法。它不允许我使用new Session().logout()。
我正在使用WatchServiceNIO。观看特定目录的两个类(Ubuntu 11.10)。
每当进行更改时,例如,如果我修改现有文件,它会触发一个MODIFIED事件 2 次。不知道为什么?当我创建新文件时它工作正常。
我创建了两个类:Initiator和Acceptor.我想从发起者向接受者发送消息,然后处理收到的消息.我无法发送消息.
这是我的initiator.java
SocketInitiator socketInitiator = null;
String fileName = "conf/intiator.cfg";
try {
SessionSettings initiatorSettings = new SessionSettings(new FileInputStream(fileName));
Application initiatorApplication = new Initiator();
FileStoreFactory fileStoreFactory = new FileStoreFactory(
initiatorSettings);
FileLogFactory fileLogFactory = new FileLogFactory(
initiatorSettings);
MessageFactory messageFactory = new DefaultMessageFactory();
socketInitiator = new SocketInitiator(initiatorApplication, fileStoreFactory, initiatorSettings, fileLogFactory, messageFactory);
socketInitiator.start();
Message msg = new Message();
msg.setString(1, "Hello this is test Message");
SessionID sessionId = (SessionID) socketInitiator.getSessions().get(0);
Session.lookupSession(sessionId).logon();
initiatorApplication.onLogon(sessionId);
initiatorApplication.toApp(msg, sessionId);
} catch (Exception e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
这是应用程序接口的overRide消息.
public void toApp(Message …Run Code Online (Sandbox Code Playgroud) 众所周知,在java-8中我们可以将函数/方法存储在变量中.通过使用以下方式.
@FunctionalInterface
public interface MyInterface {
public string getValue(int val1, int val2);
}
public class MyClass {
static String someFun(int val1, int val2) {
return ""+(val1+val2)
}
static BiFunction<Integer, Integer, String> testParamFun = (a,b) -> ""+(a+b);
public static void main(String[] args){
MyInterface intr = MyClass::someFun;
System.out.println(int.getValue(2,4)); // outpur will be "6"
/* i want this, but it give me compile time error?
I want to store that function in variable like i was doing in above case. */
MyInterface inter …Run Code Online (Sandbox Code Playgroud) 我想使用camel将.xml文件创建到csv文件中.这是我的代码
CamelContext context = new DefaultCamelContext();
from("file://Input?fileName=test.xml").marshal().csv().to("file://test?fileName=test.csv");
context.start();
Run Code Online (Sandbox Code Playgroud)
但它不会在所需的文件夹"test"中创建任何文件.
java ×8
java-8 ×2
lambda ×2
quickfix ×2
varnish ×2
apache-camel ×1
filesystems ×1
logging ×1
nio ×1
quickfixj ×1
string ×1
varnish-vcl ×1