1919import java .util .ArrayList ;
2020import java .util .List ;
2121import java .util .Map ;
22+ import java .util .concurrent .Executors ;
2223import java .util .concurrent .ScheduledExecutorService ;
2324
2425import javax .ejb .Local ;
2829
2930import org .apache .log4j .Logger ;
3031import org .springframework .stereotype .Component ;
31-
3232import org .apache .cloudstack .framework .config .dao .ConfigurationDao ;
3333
3434import com .cloud .agent .AgentManager ;
6060import com .cloud .network .ovs .dao .OvsTunnelNetworkDao ;
6161import com .cloud .network .ovs .dao .OvsTunnelNetworkVO ;
6262import com .cloud .utils .component .ManagerBase ;
63+ import com .cloud .utils .concurrency .NamedThreadFactory ;
6364import com .cloud .utils .db .DB ;
6465import com .cloud .utils .exception .CloudRuntimeException ;
6566import com .cloud .vm .DomainRouterVO ;
@@ -103,28 +104,11 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
103104 @ Override
104105 public boolean configure (String name , Map <String , Object > params )
105106 throws ConfigurationException {
106- return true ;
107- }
107+ _executorPool = Executors . newScheduledThreadPool ( 10 , new NamedThreadFactory ( "OVS" )) ;
108+ _cleanupExecutor = Executors . newScheduledThreadPool ( 1 , new NamedThreadFactory ( "OVS-Cleanup" ));
108109
109- @ DB
110- protected OvsTunnelNetworkVO createTunnelRecord (long from , long to , long networkId , int key ) {
111- OvsTunnelNetworkVO ta = null ;
112- try {
113- ta = new OvsTunnelNetworkVO (from , to , key , networkId );
114- OvsTunnelNetworkVO lock = _tunnelNetworkDao .acquireInLockTable (Long
115- .valueOf (1 ));
116- if (lock == null ) {
117- s_logger .warn ("Cannot lock table ovs_tunnel_account" );
118- return null ;
119- }
120- _tunnelNetworkDao .persist (ta );
121- _tunnelNetworkDao .releaseFromLockTable (lock .getId ());
122- } catch (EntityExistsException e ) {
123- s_logger .debug ("A record for the tunnel from " + from + " to " + to
124- + " already exists" );
125- }
126- return ta ;
127- }
110+ return true ;
111+ }
128112
129113 @ DB
130114 protected OvsTunnelInterfaceVO createInterfaceRecord (String ip ,
@@ -163,14 +147,6 @@ private String handleFetchInterfaceAnswer(Answer[] answers, Long hostId) {
163147 return null ;
164148 }
165149
166- if (_isEnabled ) {
167- _executorPool = Executors .newScheduledThreadPool (10 , new NamedThreadFactory ("OVS" ));
168- _cleanupExecutor = Executors .newScheduledThreadPool (1 , new NamedThreadFactory ("OVS-Cleanup" ));
169- }
170-
171- return true ;
172- }
173-
174150 @ DB
175151 protected OvsTunnelNetworkVO createTunnelRecord (long from , long to , long networkId , int key ) {
176152 OvsTunnelNetworkVO ta = null ;
@@ -189,37 +165,6 @@ protected OvsTunnelNetworkVO createTunnelRecord(long from, long to, long network
189165 return ta ;
190166 }
191167
192- @ DB
193- protected OvsTunnelInterfaceVO createInterfaceRecord (String ip , String netmask , String mac , long hostId , String label ) {
194- OvsTunnelInterfaceVO ti = null ;
195- try {
196- ti = new OvsTunnelInterfaceVO (ip , netmask , mac , hostId , label );
197- //TODO: Is locking really necessary here?
198- OvsTunnelInterfaceVO lock = _tunnelInterfaceDao .acquireInLockTable (Long .valueOf (1 ));
199- if (lock == null ) {
200- s_logger .warn ("Cannot lock table ovs_tunnel_account" );
201- return null ;
202- }
203- _tunnelInterfaceDao .persist (ti );
204- _tunnelInterfaceDao .releaseFromLockTable (lock .getId ());
205- } catch (EntityExistsException e ) {
206- s_logger .debug ("A record for the interface for network " + label + " on host id " + hostId + " already exists" );
207- }
208- return ti ;
209- }
210-
211- private String handleFetchInterfaceAnswer (Answer [] answers , Long hostId ) {
212- OvsFetchInterfaceAnswer ans = (OvsFetchInterfaceAnswer )answers [0 ];
213- if (ans .getResult ()) {
214- if (ans .getIp () != null && !("" .equals (ans .getIp ()))) {
215- OvsTunnelInterfaceVO ti = createInterfaceRecord (ans .getIp (), ans .getNetmask (), ans .getMac (), hostId , ans .getLabel ());
216- return ti .getIp ();
217- }
218- }
219- // Fetch interface failed!
220- s_logger .warn ("Unable to fetch the IP address for the GRE tunnel endpoint" + ans .getDetails ());
221- return null ;
222- }
223168
224169 private void handleCreateTunnelAnswer (Answer [] answers ) {
225170 OvsCreateTunnelAnswer r = (OvsCreateTunnelAnswer )answers [0 ];
0 commit comments