当前位置: 首页>>代码示例>>Java>>正文


Java InterceptorPayload类代码示例

本文整理汇总了Java中org.apache.catalina.tribes.group.InterceptorPayload的典型用法代码示例。如果您正苦于以下问题:Java InterceptorPayload类的具体用法?Java InterceptorPayload怎么用?Java InterceptorPayload使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


InterceptorPayload类属于org.apache.catalina.tribes.group包,在下文中一共展示了InterceptorPayload类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendMessage

import org.apache.catalina.tribes.group.InterceptorPayload; //导入依赖的package包/类
@Override
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException {
    if ( access.addAndGet(1) == 1 ) txStart = System.currentTimeMillis();
    long bytes = XByteBuffer.getDataPackageLength(((ChannelData)msg).getDataPackageLength());
    try {
        super.sendMessage(destination, msg, payload);
    }catch ( ChannelException x ) {
        msgTxErr.addAndGet(1);
        if ( access.get() == 1 ) access.addAndGet(-1);
        throw x;
    } 
    mbTx += (bytes*destination.length)/(1024d*1024d);
    mbAppTx += bytes/(1024d*1024d);
    if ( access.addAndGet(-1) == 0 ) {
        long stop = System.currentTimeMillis();
        timeTx += (stop - txStart) / 1000d;
        if ((msgTxCnt.get() / interval) >= lastCnt) {
            lastCnt++;
            report(timeTx);
        }
    }
    msgTxCnt.addAndGet(1);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:24,代码来源:ThroughputInterceptor.java

示例2: sendMessage

import org.apache.catalina.tribes.group.InterceptorPayload; //导入依赖的package包/类
@Override
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload)
		throws ChannelException {
	if (access.addAndGet(1) == 1)
		txStart = System.currentTimeMillis();
	long bytes = XByteBuffer.getDataPackageLength(((ChannelData) msg).getDataPackageLength());
	try {
		super.sendMessage(destination, msg, payload);
	} catch (ChannelException x) {
		msgTxErr.addAndGet(1);
		if (access.get() == 1)
			access.addAndGet(-1);
		throw x;
	}
	mbTx += (bytes * destination.length) / (1024d * 1024d);
	mbAppTx += bytes / (1024d * 1024d);
	if (access.addAndGet(-1) == 0) {
		long stop = System.currentTimeMillis();
		timeTx += (stop - txStart) / 1000d;
		if ((msgTxCnt.get() / interval) >= lastCnt) {
			lastCnt++;
			report(timeTx);
		}
	}
	msgTxCnt.addAndGet(1);
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:27,代码来源:ThroughputInterceptor.java

示例3: sendMessage

import org.apache.catalina.tribes.group.InterceptorPayload; //导入依赖的package包/类
@Override
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload)
		throws ChannelException {
	try {
		super.sendMessage(destination, msg, payload);
	} catch (ChannelException cx) {
		FaultyMember[] mbrs = cx.getFaultyMembers();
		for (int i = 0; i < mbrs.length; i++) {
			if (mbrs[i].getCause() != null && (!(mbrs[i].getCause() instanceof RemoteProcessException))) {// RemoteProcessException's
																											// are
																											// ok
				this.memberDisappeared(mbrs[i].getMember());
			} // end if
		} // for
		throw cx;
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:18,代码来源:TcpFailureDetector.java

示例4: sendMessage

import org.apache.catalina.tribes.group.InterceptorPayload; //导入依赖的package包/类
@Override
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException {
    boolean async = (msg.getOptions() & Channel.SEND_OPTIONS_ASYNCHRONOUS) == Channel.SEND_OPTIONS_ASYNCHRONOUS;
    if ( async && run ) {
        if ( (getCurrentSize()+msg.getMessage().getLength()) > maxQueueSize ) {
            if ( alwaysSend ) {
                super.sendMessage(destination,msg,payload);
                return;
            } else {
                throw new ChannelException("Asynchronous queue is full, reached its limit of " + maxQueueSize +" bytes, current:" + getCurrentSize() + " bytes.");
            }//end if
        }//end if
        //add to queue
        if ( useDeepClone ) msg = (ChannelMessage)msg.deepclone();
        if (!addToQueue(msg, destination, payload) ) {
            throw new ChannelException("Unable to add the message to the async queue, queue bug?");
        }
        addAndGetCurrentSize(msg.getMessage().getLength());
    } else {
        super.sendMessage(destination, msg, payload);
    }
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:23,代码来源:MessageDispatchInterceptor.java

示例5: sendMessage

import org.apache.catalina.tribes.group.InterceptorPayload; //导入依赖的package包/类
@Override
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws
    ChannelException {
    //todo, optimize, if destination.length==1, then we can do
    //msg.setOptions(msg.getOptions() & (~getOptionFlag())
    //and just send one message
    if (okToProcess(msg.getOptions()) ) {
        super.sendMessage(destination, msg, null);
        ChannelMessage confirmation = null;
        if ( deepclone ) confirmation = (ChannelMessage)msg.deepclone();
        else confirmation = (ChannelMessage)msg.clone();
        confirmation.getMessage().reset();
        UUIDGenerator.randomUUID(false,confirmation.getUniqueId(),0);
        confirmation.getMessage().append(START_DATA,0,START_DATA.length);
        confirmation.getMessage().append(msg.getUniqueId(),0,msg.getUniqueId().length);
        confirmation.getMessage().append(END_DATA,0,END_DATA.length);
        super.sendMessage(destination,confirmation,payload);
    } else {
        //turn off two phase commit
        //this wont work if the interceptor has 0 as a flag
        //since there is no flag to turn off
        //msg.setOptions(msg.getOptions() & (~getOptionFlag()));
        super.sendMessage(destination, msg, payload);
    }
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:26,代码来源:TwoPhaseCommitInterceptor.java

示例6: sendMessage

import org.apache.catalina.tribes.group.InterceptorPayload; //导入依赖的package包/类
@Override
public synchronized void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException {
    if ( hold == null ) {
        //System.out.println("Skipping message:"+msg);
        hold = (ChannelMessage)msg.deepclone();
        dest = new Member[destination.length];
        System.arraycopy(destination,0,dest,0,dest.length);
    } else {
        //System.out.println("Sending message:"+msg);
        super.sendMessage(destination,msg,payload);
        //System.out.println("Sending message:"+hold);
        super.sendMessage(dest,hold,null);
        hold = null;
        dest = null;
    }
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:17,代码来源:TestOrderInterceptor.java

示例7: sendMessage

import org.apache.catalina.tribes.group.InterceptorPayload; //导入依赖的package包/类
@Override
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException {
    try {
        super.sendMessage(destination, msg, payload);
    }catch ( ChannelException cx ) {
        FaultyMember[] mbrs = cx.getFaultyMembers();
        for ( int i=0; i<mbrs.length; i++ ) {
            if ( mbrs[i].getCause()!=null &&
                 (!(mbrs[i].getCause() instanceof RemoteProcessException)) ) {//RemoteProcessException's are ok
                this.memberDisappeared(mbrs[i].getMember());
            }//end if
        }//for
        throw cx;
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:16,代码来源:TcpFailureDetector.java

示例8: sendMessage

import org.apache.catalina.tribes.group.InterceptorPayload; //导入依赖的package包/类
@Override
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException {
    if ( !okToProcess(msg.getOptions()) ) {
        super.sendMessage(destination, msg, payload);
        return;
    }
    ChannelException cx = null;
    for (int i=0; i<destination.length; i++ ) {
        try {
            int nr = 0;
            try {
                outLock.writeLock().lock();
                nr = incCounter(destination[i]);
            } finally {
                outLock.writeLock().unlock();
            }
            //reduce byte copy
            msg.getMessage().append(nr);
            try {
                getNext().sendMessage(new Member[] {destination[i]}, msg, payload);
            } finally {
                msg.getMessage().trim(4);
            }
        }catch ( ChannelException x ) {
            if ( cx == null ) cx = x;
            cx.addFaultyMember(x.getFaultyMembers());
        }
    }//for
    if ( cx != null ) throw cx;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:31,代码来源:OrderInterceptor.java

示例9: addToQueue

import org.apache.catalina.tribes.group.InterceptorPayload; //导入依赖的package包/类
@Override
public boolean addToQueue(ChannelMessage msg, Member[] destination, InterceptorPayload payload) {
    final LinkObject obj = new LinkObject(msg,destination,payload);
    Runnable r = new Runnable() {
        @Override
        public void run() {
            sendAsyncData(obj);
        }
    };
    executor.execute(r);
    return true;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:13,代码来源:MessageDispatch15Interceptor.java

示例10: sendMessage

import org.apache.catalina.tribes.group.InterceptorPayload; //导入依赖的package包/类
@Override
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException {
    int size = msg.getMessage().getLength();
    boolean frag = (size>maxSize) && okToProcess(msg.getOptions());
    if ( frag ) {
        frag(destination, msg, payload);
    } else {
        msg.getMessage().append(frag);
        super.sendMessage(destination, msg, payload);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:12,代码来源:FragmentationInterceptor.java

示例11: frag

import org.apache.catalina.tribes.group.InterceptorPayload; //导入依赖的package包/类
public void frag(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException {
    int size = msg.getMessage().getLength();

    int count = ((size / maxSize )+(size%maxSize==0?0:1));
    ChannelMessage[] messages = new ChannelMessage[count];
    int remaining = size;
    for ( int i=0; i<count; i++ ) {
        ChannelMessage tmp = (ChannelMessage)msg.clone();
        int offset = (i*maxSize);
        int length = Math.min(remaining,maxSize);
        tmp.getMessage().clear();
        tmp.getMessage().append(msg.getMessage().getBytesDirect(),offset,length);
        //add the msg nr
        //tmp.getMessage().append(XByteBuffer.toBytes(i),0,4);
        tmp.getMessage().append(i);
        //add the total nr of messages
        //tmp.getMessage().append(XByteBuffer.toBytes(count),0,4);
        tmp.getMessage().append(count);
        //add true as the frag flag
        //byte[] flag = XByteBuffer.toBytes(true);
        //tmp.getMessage().append(flag,0,flag.length);
        tmp.getMessage().append(true);
        messages[i] = tmp;
        remaining -= length;
        
    }
    for ( int i=0; i<messages.length; i++ ) {
        super.sendMessage(destination,messages[i],payload);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:31,代码来源:FragmentationInterceptor.java

示例12: sendMessage

import org.apache.catalina.tribes.group.InterceptorPayload; //导入依赖的package包/类
@Override
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException {
    try {
        byte[] data = compress(msg.getMessage().getBytes());
        msg.getMessage().trim(msg.getMessage().getLength());
        msg.getMessage().append(data,0,data.length);
        getNext().sendMessage(destination, msg, payload);
    } catch ( IOException x ) {
        log.error("Unable to compress byte contents");
        throw new ChannelException(x);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:13,代码来源:GzipInterceptor.java

示例13: sendMessage

import org.apache.catalina.tribes.group.InterceptorPayload; //导入依赖的package包/类
@Override
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload)
		throws ChannelException {
	if (!okToProcess(msg.getOptions())) {
		super.sendMessage(destination, msg, payload);
		return;
	}
	ChannelException cx = null;
	for (int i = 0; i < destination.length; i++) {
		try {
			int nr = 0;
			try {
				outLock.writeLock().lock();
				nr = incCounter(destination[i]);
			} finally {
				outLock.writeLock().unlock();
			}
			// reduce byte copy
			msg.getMessage().append(nr);
			try {
				getNext().sendMessage(new Member[] { destination[i] }, msg, payload);
			} finally {
				msg.getMessage().trim(4);
			}
		} catch (ChannelException x) {
			if (cx == null)
				cx = x;
			cx.addFaultyMember(x.getFaultyMembers());
		}
	} // for
	if (cx != null)
		throw cx;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:34,代码来源:OrderInterceptor.java

示例14: addToQueue

import org.apache.catalina.tribes.group.InterceptorPayload; //导入依赖的package包/类
@Override
public boolean addToQueue(ChannelMessage msg, Member[] destination, InterceptorPayload payload) {
	final LinkObject obj = new LinkObject(msg, destination, payload);
	Runnable r = new Runnable() {
		@Override
		public void run() {
			sendAsyncData(obj);
		}
	};
	executor.execute(r);
	return true;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:13,代码来源:MessageDispatch15Interceptor.java

示例15: sendMessage

import org.apache.catalina.tribes.group.InterceptorPayload; //导入依赖的package包/类
@Override
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload)
		throws ChannelException {
	int size = msg.getMessage().getLength();
	boolean frag = (size > maxSize) && okToProcess(msg.getOptions());
	if (frag) {
		frag(destination, msg, payload);
	} else {
		msg.getMessage().append(frag);
		super.sendMessage(destination, msg, payload);
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:13,代码来源:FragmentationInterceptor.java


注:本文中的org.apache.catalina.tribes.group.InterceptorPayload类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。