Add Neutron host-id to RLOC mapping
[lispflowmapping.git] / mappingservice / neutron / src / main / java / org / opendaylight / lispflowmapping / neutron / intenthandler / IntentHandlerAsyncExecutorProvider.java
1 /*
2  * Copyright (c) 2017 Cisco Systems, Inc.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.lispflowmapping.neutron.intenthandler;
9
10 import com.google.common.util.concurrent.ListeningExecutorService;
11 import com.google.common.util.concurrent.MoreExecutors;
12
13 import java.util.concurrent.Executors;
14
15 /**
16  * Created by Shakib Ahmed on 1/24/17.
17  */
18 public class IntentHandlerAsyncExecutorProvider {
19     private static ListeningExecutorService listeningExecutorService;
20
21     private static final int EXTRA_THREADS_TO_HANDLE_VPP_LISTENER = 1;
22
23     private static IntentHandlerAsyncExecutorProvider intentHandlerAsyncExecutorProvider;
24
25     private IntentHandlerAsyncExecutorProvider() {
26         listeningExecutorService = MoreExecutors
27                 .listeningDecorator(Executors.newFixedThreadPool(EXTRA_THREADS_TO_HANDLE_VPP_LISTENER));
28     }
29
30     public static synchronized IntentHandlerAsyncExecutorProvider getInstace() {
31         if (intentHandlerAsyncExecutorProvider == null) {
32             intentHandlerAsyncExecutorProvider = new IntentHandlerAsyncExecutorProvider();
33         }
34         return intentHandlerAsyncExecutorProvider;
35     }
36
37     public synchronized ListeningExecutorService getExecutor() {
38         return listeningExecutorService;
39     }
40
41     public void close() {
42         listeningExecutorService.shutdown();
43     }
44 }