2 * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
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
8 package org.opendaylight.netvirt.elan.l2gw.ha.listeners;
10 import com.google.common.util.concurrent.ThreadFactoryBuilder;
12 import java.util.concurrent.Callable;
13 import java.util.concurrent.ExecutorService;
14 import java.util.concurrent.Executors;
15 import java.util.concurrent.Future;
16 import java.util.concurrent.ThreadFactory;
19 public class HAJobScheduler {
21 ExecutorService executorService;
23 static HAJobScheduler instance = new HAJobScheduler();
25 private HAJobScheduler() {
26 ThreadFactory threadFact = new ThreadFactoryBuilder()
27 .setNameFormat("hwvtep-ha-task-%d").build();
28 executorService = Executors.newSingleThreadScheduledExecutor(threadFact);
31 public static HAJobScheduler getInstance() {
35 public void setThreadPool(ExecutorService service) {
36 executorService = service;
39 public Future<Void> submitJob(Callable<Void> callable) {
40 return executorService.submit(callable);
43 public void submitJob(Runnable runnable) {
44 executorService.submit(runnable);