@@ -0,0 +1,3552 @@
+/*%0A * Licensed to the Apache Software Foundation (ASF) under one%0A * or more contributor license agreements.  See the NOTICE file%0A * distributed with this work for additional information%0A * regarding copyright ownership.  The ASF licenses this file%0A * to you under the Apache License, Version 2.0 (the%0A * %22License%22); you may not use this file except in compliance%0A * with the License.  You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.apache.cassandra.net;%0A%0Aimport org.apache.cassandra.concurrent.Stage;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Apublic class Chen_MessageDeliveryTask implements Runnable, Comparable%3CChen_MessageDeliveryTask%3E%0A%7B%0A    private static final Logger logger = LoggerFactory.getLogger(MessageDeliveryTask.class);%0A%0A    private final MessageIn message;%0A    private final long constructionTime;%0A    private final int id;%0A    %0A    protected long priority;%0A    protected boolean installed;%0A%0A    public Chen_MessageDeliveryTask(MessageIn message, int id, long timestamp)%0A    %7B%0A        assert message != null;%0A        this.message = message;%0A        this.id = id;%0A        constructionTime = timestamp;%0A        %0A        priority = -1;%0A        installed = false;%0A    %7D%0A%0A    public void run()%0A    %7B%0A        MessagingService.Verb verb = message.verb;%0A        if (MessagingService.DROPPABLE_VERBS.contains(verb)%0A            && System.currentTimeMillis() %3E constructionTime + message.getTimeout())%0A        %7B%0A            MessagingService.instance().incrementDroppedMessages(verb);%0A            return;%0A        %7D%0A%0A        IVerbHandler verbHandler = MessagingService.instance().getVerbHandler(verb);%0A        if (verbHandler == null)%0A        %7B%0A            logger.debug(%22Unknown verb %7B%7D%22, verb);%0A            return;%0A        %7D%0A%0A        verbHandler.doVerb(message, id);%0A    %7D%0A%0A    @Override%0A    public int compareTo(Chen_MessageDeliveryTask o)%0A    %7B%0A        if (message.getMessageType() == Stage.READ)%0A        %7B%0A          //this -------%3E READ message%0A            if (o.message.getMessageType() == Stage.READ)%0A            %7B%0A                //this -------%3E READ message%0A                return (int)(o.priority - priority);%0A            %7D%0A            else %7B%0A                // o -------%3E MUTATION message%0A                return compare_READ_MUTATION(this, o);%0A            %7D%0A        %7D%0A        else %7B%0A            //this ------%3E MUTATION message%0A            if (o.message.getMessageType() == Stage.MUTATION)%0A            %7B%0A              //o ------%3E MUTATION message%0A                return (int)(o.priority - priority);%0A            %7D%0A            else %7B%0A                // this --------%3E READ message%0A                return compare_READ_MUTATION(o, this);%0A            %7D%0A        %7D%0A    %7D%0A%0A    private int compare_READ_MUTATION(Chen_MessageDeliveryTask read_task,%0A            Chen_MessageDeliveryTask mutation_task)%0A    %7B%0A        if (read_task.priority == mutation_task.priority)%0A        %7B%0A            if (read_task.installed)%0A            %7B%0A                return -1;%0A            %7D%0A            else %7B%0A                return 1;%0A            %7D%0A        %7D%0A        else %7B%0A            return (int)(read_task.priority - mutation_task.priority);%0A        %7D%0A        %0A    %7D%0A%7D

add Chen_MessageDeliveryTask