[ 
https://issues.apache.org/jira/browse/ARTEMIS-2239?focusedWorklogId=190292&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-190292
 ]

ASF GitHub Bot logged work on ARTEMIS-2239:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 26/Jan/19 02:08
            Start Date: 26/Jan/19 02:08
    Worklog Time Spent: 10m 
      Work Description: michaelandrepearce commented on pull request #2522: 
ARTEMIS-2239 Zero-copy NIO/MAPPED TimedBuffer
URL: https://github.com/apache/activemq-artemis/pull/2522#discussion_r251183788
 
 

 ##########
 File path: 
artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/DelegateCallback.java
 ##########
 @@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.core.io;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Objects;
+
+import org.apache.activemq.artemis.journal.ActiveMQJournalLogger;
+
+/**
+ * It is a utility class to allow several {@link IOCallback}s to be used as 
one.
+ */
+public final class DelegateCallback implements IOCallback {
+
+   private final List<IOCallback> delegates;
+
+   /**
+    * It doesn't copy defensively the given {@code delegates}.
+    *
+    * @throws NullPointerException if {@code delegates} is {@code null}
+    */
+   public DelegateCallback(final List<IOCallback> delegates) {
+      Objects.requireNonNull(delegates, "delegates cannot be null!");
+      this.delegates = delegates;
+   }
+
+   @Override
+   public void done() {
+      done(delegates);
+   }
+
+   @Override
+   public void onError(final int errorCode, final String errorMessage) {
+      onError(delegates, errorCode, errorMessage);
+   }
+
+   public static void done(Collection<IOCallback> delegates) {
+      delegates.forEach(callback -> {
+         try {
+            callback.done();
+         } catch (Throwable e) {
+            ActiveMQJournalLogger.LOGGER.errorCompletingCallback(e);
+         }
+      });
+   }
+
+   public static void onError(Collection<IOCallback> delegates, int errorCode, 
final String errorMessage) {
 
 Review comment:
   ditto as per other static method, thats takes IOCallback
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 190292)
    Time Spent: 3h 10m  (was: 3h)

> Zero-copy NIO/MAPPED TimedBuffer
> --------------------------------
>
>                 Key: ARTEMIS-2239
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-2239
>             Project: ActiveMQ Artemis
>          Issue Type: Improvement
>          Components: Broker
>    Affects Versions: 2.6.4
>            Reporter: Francesco Nigro
>            Assignee: Francesco Nigro
>            Priority: Major
>          Time Spent: 3h 10m
>  Remaining Estimate: 0h
>
> NIO/MAPPED journal types are currently performing the copy of the buffer used 
> on TimedBuffer to accumulate writes, but this copy (and the zeroing of the 
> new buffer) could be avoided, reducing dramatically the CPU usage and 
> latencies during a burst of writes.
> An added benefit of this change is that isn't necessary anymore to stress the 
> thread pool of the file factory, because there is no need to pool the buffer 
> used to perform the write.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to