Skip to content

Commit 792fdf9

Browse files
author
Kelven Yang
committed
1) Add host_master table for tracking VMWare vShpere servers
2) Add SynchronizationEvent for in-process event synchronization 3) Move VMware files out of FOSS code base
1 parent b3cf83c commit 792fdf9

7 files changed

Lines changed: 109 additions & 210 deletions

File tree

‎core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java‎

Lines changed: 0 additions & 130 deletions
This file was deleted.

‎core/test/com/cloud/vmware/TestVMWare.java‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,12 @@ private void addNicToNetwork() throws Exception {
778778
"dvPortGroup-vlan26", vNicSpec);
779779
}
780780

781+
private void createDatacenter() throws Exception {
782+
cb.getServiceConnection3().getService().createDatacenter(
783+
cb.getServiceConnection3().getRootFolder(),
784+
"cloud.dc.test");
785+
}
786+
781787
public static void main(String[] args) throws Exception {
782788
setupLog4j();
783789
TestVMWare client = new TestVMWare();
@@ -800,8 +806,10 @@ public static void main(String[] args) throws Exception {
800806
// client.createSnapshot();
801807
// client.registerTemplate();
802808
// client.createVmFromTemplate();
803-
client.addNic();
809+
// client.addNic();
804810
// client.addNicToNetwork();
811+
812+
client.createDatacenter();
805813
cb.disConnect();
806814
} catch (Exception e) {
807815
e.printStackTrace();

‎server/src/com/cloud/hypervisor/vmware/discoverer/VmwareServerDiscoverer.java‎

Lines changed: 0 additions & 40 deletions
This file was deleted.

‎setup/db/create-index-fk.sql‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,6 @@ ALTER TABLE `cloud`.`network_group_vm_map` ADD CONSTRAINT `fk_network_group_vm_m
250250

251251
ALTER TABLE `cloud`.`op_nwgrp_work` ADD INDEX `i_op_nwgrp_work__instance_id`(`instance_id`);
252252
ALTER TABLE `cloud`.`op_nwgrp_work` ADD INDEX `i_op_nwgrp_work__mgmt_server_id`(`mgmt_server_id`);
253+
254+
ALTER TABLE `cloud`.`host_master` ADD UNIQUE `i_host_master__service_address`(`service_address`);
255+

‎setup/db/create-schema.sql‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ DROP TABLE IF EXISTS `cloud`.`cluster`;
7676
DROP TABLE IF EXISTS `cloud`.`nics`;
7777
DROP TABLE IF EXISTS `cloud`.`network_profiles`;
7878
DROP TABLE IF EXISTS `cloud`.`network_offerings`;
79+
DROP TABLE IF EXISTS `cloud`.`host_master`;
7980

8081
CREATE TABLE `cloud`.`network_profiles` (
8182
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
@@ -1044,4 +1045,13 @@ CREATE TABLE `cloud`.`op_vm_ruleset_log` (
10441045
PRIMARY KEY (`id`)
10451046
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
10461047

1048+
CREATE TABLE `cloud`.`host_master` (
1049+
`id` bigint unsigned UNIQUE NOT NULL AUTO_INCREMENT COMMENT 'id',
1050+
`type` varchar(32) NOT NULL,
1051+
`service_address` varchar(255) NOT NULL,
1052+
`admin` varchar(32) NOT NULL,
1053+
`password` varchar(32),
1054+
PRIMARY KEY (`id`)
1055+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1056+
10471057
SET foreign_key_checks = 1;
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/**
2+
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
3+
*
4+
* This software is licensed under the GNU General Public License v3 or later.
5+
*
6+
* It is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or any later version.
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
*/
18+
package com.cloud.utils.concurrency;
19+
20+
import org.apache.log4j.Logger;
21+
22+
public class SynchronizationEvent {
23+
protected final static Logger s_logger = Logger.getLogger(SynchronizationEvent.class);
24+
25+
private boolean signalled;
26+
27+
public SynchronizationEvent() {
28+
signalled = false;
29+
}
30+
31+
public SynchronizationEvent(boolean signalled) {
32+
this.signalled = signalled;
33+
}
34+
35+
public void setEvent() {
36+
synchronized(this) {
37+
signalled = true;
38+
notifyAll();
39+
}
40+
}
41+
42+
public void resetEvent() {
43+
synchronized(this) {
44+
signalled = false;
45+
}
46+
}
47+
48+
public boolean waitEvent() {
49+
synchronized(this) {
50+
if(signalled)
51+
return true;
52+
53+
while(true) {
54+
try {
55+
wait();
56+
assert(signalled);
57+
return signalled;
58+
} catch (InterruptedException e) {
59+
s_logger.debug("unexpected awaken signal in wait()");
60+
}
61+
}
62+
}
63+
}
64+
65+
public boolean waitEvent(long timeOutMiliseconds) {
66+
synchronized(this) {
67+
if(signalled)
68+
return true;
69+
70+
try {
71+
wait(timeOutMiliseconds);
72+
return signalled;
73+
} catch (InterruptedException e) {
74+
// TODO, we don't honor time out semantics when the waiting thread is interrupted
75+
s_logger.debug("unexpected awaken signal in wait(...)");
76+
return false;
77+
}
78+
}
79+
}
80+
81+
public boolean isSignalled() {
82+
synchronized(this) {
83+
return signalled;
84+
}
85+
}
86+
}

‎utils/src/com/cloud/utils/db/GlobalLock.java‎

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,6 @@
4141
// }
4242
// lock.releaseRef();
4343
//
44-
//
45-
// GlobalLock.Auto lock = GlobalLock.getAutoInternLock("some table name" + rowId);
46-
// if(lock.lock()) {
47-
// try {
48-
// do something
49-
// } finally {
50-
// lock.unlock();
51-
// }
52-
// }
53-
//
5444
public class GlobalLock {
5545
protected final static Logger s_logger = Logger.getLogger(GlobalLock.class);
5646

@@ -92,11 +82,7 @@ public int releaseRef() {
9282
releaseInternLock(name);
9383
return refCount;
9484
}
95-
96-
public static GlobalLock.Auto getAutoInternLock(String name) {
97-
return new GlobalLock.Auto(getInternLock(name));
98-
}
99-
85+
10086
public static GlobalLock getInternLock(String name) {
10187
synchronized(s_lockMap) {
10288
if(s_lockMap.containsKey(name)) {
@@ -203,28 +189,4 @@ public boolean unlock() {
203189
public String getName() {
204190
return name;
205191
}
206-
207-
public static class Auto {
208-
private GlobalLock lock;
209-
210-
public Auto(GlobalLock lock) {
211-
this.lock = lock;
212-
}
213-
214-
protected void finalize() throws Throwable {
215-
try {
216-
lock.releaseRef();
217-
} finally {
218-
super.finalize();
219-
}
220-
}
221-
222-
public boolean lock(int timeoutSeconds) {
223-
return lock.lock(timeoutSeconds);
224-
}
225-
226-
public boolean unlock() {
227-
return lock.unlock();
228-
}
229-
}
230192
}

0 commit comments

Comments
 (0)