Skip to content

Commit 30fb351

Browse files
Neil DEVASNeil DEVAS
authored andcommitted
fix bugs and scripts
1 parent 30111bd commit 30fb351

19 files changed

+147
-88
lines changed

code/Server/Server/Common/CarResourceManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public int queryCarsPrice(int xid, String location) throws RemoteException {
6060
public boolean reserveItem(int xid, int customerID, String key, String location) throws RemoteException {
6161
Trace.info("RM::reserveItem(" + xid + ", customer=" + customerID + ", " + key + ", " + location + ") called");
6262
// Read customer object if it exists (and read lock it)
63-
Customer customer = null;
63+
ICustomer customer = null;
6464
try {
6565
customer = customerRM.getCustomer(xid, customerID);
6666
if (customer == null) {
@@ -82,7 +82,7 @@ public boolean reserveItem(int xid, int customerID, String key, String location)
8282
return false;
8383
} else {
8484
customer.reserve(key, location, item.getPrice());
85-
writeData(xid, customer.getKey(), customer);
85+
//writeData(xid, customer.getKey(), customer); // TODO why is this needed?
8686

8787
// Decrease the number of available items in the storage
8888
item.setCount(item.getCount() - 1);

code/Server/Server/Common/Customer.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ public boolean reserve(String key, String location, int price) {
4141
// NOTE: latest price overrides existing price
4242
reservedItem.setPrice(price);
4343
}
44+
System.out.println("I JUST PUT INTO HASHMAP");
4445
m_reservations.put(reservedItem.getKey(), reservedItem);
46+
System.out.println("BSLD" + m_reservations.keySet().size());
4547
return true;
4648
}
4749
}
@@ -51,9 +53,13 @@ public ReservedItem getReservedItem(String key) {
5153
}
5254

5355
public String getBill() {
56+
// System.out.println("GEtting bill!!!!!");
5457
String s = "Bill for customer " + m_ID + "\n";
58+
// System.out.println("CUSTOMER KEY SET LENGTH" + m_reservations.keySet());
5559
for (String key : m_reservations.keySet()) {
60+
// System.out.println("INSIDE FOR LOOP");
5661
ReservedItem item = (ReservedItem) m_reservations.get(key);
62+
System.out.println("ITEM KEY: " + item.getReservableItemKey());
5763
s += +item.getCount() + " " + item.getReservableItemKey() + " $" + item.getPrice() + "\n";
5864
}
5965
return s;

code/Server/Server/Common/CustomerResourceManager.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public boolean deleteCustomer(int xid, int customerID) throws RemoteException {
7070
}
7171

7272
public String queryCustomerInfo(int xid, int customerID) throws RemoteException {
73+
System.out.println("INSIDE QUERY CUSTOMER INFO!!!!!!!!!!!!!!!");
7374
Trace.info("RM::queryCustomerInfo(" + xid + ", " + customerID + ") called");
7475
Customer customer = (Customer) readData(xid, Customer.getKey(customerID));
7576
if (customer == null) {

code/Server/Server/Common/FlightResourceManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public String getName() throws RemoteException {
6464
public boolean reserveItem(int xid, int customerID, String key, String location) throws RemoteException {
6565
Trace.info("RM::reserveItem(" + xid + ", customer=" + customerID + ", " + key + ", " + location + ") called");
6666
// Read customer object if it exists (and read lock it)
67-
Customer customer = null;
67+
ICustomer customer = null;
6868
try {
6969
customer = customerRM.getCustomer(xid, customerID);
7070
if (customer == null) {
@@ -86,7 +86,7 @@ public boolean reserveItem(int xid, int customerID, String key, String location)
8686
return false;
8787
} else {
8888
customer.reserve(key, location, item.getPrice());
89-
writeData(xid, customer.getKey(), customer);
89+
//writeData(xid, customer.getKey(), customer); TODO: why do we need this line
9090

9191
// Decrease the number of available items in the storage
9292
item.setCount(item.getCount() - 1);

code/Server/Server/Common/RoomResourceManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public String getName() throws RemoteException {
6464
public boolean reserveItem(int xid, int customerID, String key, String location) throws RemoteException {
6565
Trace.info("RM::reserveItem(" + xid + ", customer=" + customerID + ", " + key + ", " + location + ") called");
6666
// Read customer object if it exists (and read lock it)
67-
Customer customer = null;
67+
ICustomer customer = null;
6868
try {
6969
customer = customerRM.getCustomer(xid, customerID);
7070
if (customer == null) {
@@ -86,7 +86,7 @@ public boolean reserveItem(int xid, int customerID, String key, String location)
8686
return false;
8787
} else {
8888
customer.reserve(key, location, item.getPrice());
89-
writeData(xid, customer.getKey(), customer);
89+
///writeData(xid, customer.getKey(), customer); // TODO: why do we need this line
9090

9191
// Decrease the number of available items in the storage
9292
item.setCount(item.getCount() - 1);

code/Server/Server/Interface/ICustomerResourceManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import Server.Common.Customer;
44
import Server.TCP.IProxiable;
5+
import Server.Interface.ICustomer;
56

67
import java.rmi.Remote;
78
import java.rmi.RemoteException;
@@ -54,6 +55,6 @@ public String getName()
5455
*
5556
* @return the customer
5657
*/
57-
public Customer getCustomer(int xid, int customerID)
58+
public ICustomer getCustomer(int xid, int customerID)
5859
throws RemoteException;
5960
}

code/Server/Server/TCP/AbstractProxyObject.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ protected Message sendAndReceiveMessage(Message messageToSend)
2828
throws UnknownHostException, IOException, ClassNotFoundException
2929
{
3030
messageToSend.proxyObjectBoundName = boundName;
31-
31+
System.out.println("Socket ateempting to create on hostname and port: " + hostname + ", " + port);
3232
Socket socket = new Socket(hostname, port);
33-
3433
ObjectOutputStream objectOutput =
3534
new ObjectOutputStream(socket.getOutputStream());
3635
ObjectInputStream objectInput =

code/Server/Server/TCP/ProxyCustomer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public boolean reserve(String key, String location, int price) {
5252
message.proxyObjectBoundName = this.boundName;
5353
message.methodName = "reserve";
5454
message.methodArgs = new Object[]{key, location, price};
55-
message.methodArgTypes = new Class[]{String.class, String.class, String.class};
55+
message.methodArgTypes = new Class[]{String.class, String.class, int.class};
5656
Message recvMessage = null;
5757
try {
5858
recvMessage = sendAndReceiveMessage(message);

code/Server/Server/TCP/ProxyCustomerResourceManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public String getName() throws RemoteException {
122122
*
123123
* @return the customer
124124
*/
125-
public Customer getCustomer(int xid, int customerID) throws RemoteException {
125+
public ICustomer getCustomer(int xid, int customerID) throws RemoteException {
126126
ProxyMethodCallMessage message = new ProxyMethodCallMessage();
127127
message.proxyObjectBoundName = this.boundName;
128128
message.methodName = "getCustomer";
@@ -140,7 +140,7 @@ public Customer getCustomer(int xid, int customerID) throws RemoteException {
140140
Trace.info("ProxyCustomerResourceManager::getCustomer(" + xid + "," + customerID + ") -> requestedValue is null");
141141
throw new RemoteException("Oh no!");
142142
} else {
143-
return (Customer) recvMessage.requestedValue;
143+
return (ICustomer) recvMessage.requestedValue;
144144
}
145145
}
146146

code/Server/Server/TCP/ProxyFlightResourceManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public boolean reserveFlight(int id, int customerID, int flightNumber) throws Re
116116
message.proxyObjectBoundName = this.boundName;
117117
message.methodName = "reserveFlight";
118118
message.methodArgs = new Object[]{id, customerID, flightNumber};
119-
message.methodArgTypes = new Class[]{int.class, int.class, String.class};
119+
message.methodArgTypes = new Class[]{int.class, int.class, int.class};
120120

121121
Message recvMessage = null;
122122
try {

0 commit comments

Comments
 (0)