Skip to content

Commit a6a1303

Browse files
committed
1 parent 0a34c60 commit a6a1303

File tree

5 files changed

+50
-14
lines changed

5 files changed

+50
-14
lines changed

myperf/src/main/java/com/yahoo/dba/perf/myperf/common/DBInstanceInfo.java

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*/
1313
public class DBInstanceInfo implements java.io.Serializable{
1414
private static final long serialVersionUID = 1L;
15+
private static final int MAX_16BIT_UINT = 65536;
1516

1617
private int instance = 0;//keep it for future to include Oracle
1718

@@ -68,20 +69,32 @@ public String getPort()
6869

6970
public void setPort(String port)
7071
{
71-
this.port = port;
72+
if(port!=null)
73+
{
74+
try
75+
{
76+
int lp = Integer.parseInt(port);
77+
if(lp<0)
78+
{
79+
lp = MAX_16BIT_UINT + lp;
80+
}
81+
this.port = String.valueOf(lp);
82+
}catch(Exception ex){}
83+
}
84+
else this.port = port;
7285
}
7386

7487
public short getPortShort()
7588
{
76-
short lp = 0;
89+
int lp = 0;
7790
try
7891
{
79-
lp = Short.valueOf(this.port);
92+
lp = Integer.valueOf(this.port);
8093
}catch(Exception ex)
8194
{
8295

8396
}
84-
return lp;
97+
return (short)lp;
8598
}
8699

87100
public boolean isUseTunneling()
@@ -113,19 +126,35 @@ public String getLocalPort()
113126

114127
public void setLocalPort(String localPort)
115128
{
116-
this.localPort = localPort;
129+
if(localPort != null)
130+
{
131+
try
132+
{
133+
int lp = Integer.parseInt(localPort);
134+
if(lp <0 )
135+
{
136+
lp = MAX_16BIT_UINT + lp;
137+
}
138+
this.localPort = String.valueOf(lp);
139+
140+
}catch(Exception ex)
141+
{
142+
143+
}
144+
}
145+
else this.localPort = localPort;
117146
}
118147

119148
public short getLocalPortShort()
120149
{
121-
short lp = 0;
150+
int lp = 0;
122151
try
123152
{
124-
lp = Short.valueOf(this.localPort);
153+
lp = Integer.valueOf(this.localPort);
125154
}catch(Exception ex)
126155
{
127156
}
128-
return lp;
157+
return (short)lp;
129158
}
130159

131160
public int getInstance()

myperf/src/main/java/com/yahoo/dba/perf/myperf/metrics/MetricsDbBase.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,14 +1650,14 @@ public boolean upsertDBInfo(Connection conn, DBInstanceInfo dbinfo, boolean inse
16501650
pstmt.setString(idx++, dbinfo.getHostName().toLowerCase());
16511651
pstmt.setString(idx++, dbinfo.getDbType());
16521652
pstmt.setString(idx++, String.valueOf(dbinfo.getInstance()));
1653-
if(dbinfo.getPortShort()>0)
1653+
if(dbinfo.getPortShort() != 0)
16541654
pstmt.setShort(idx++, dbinfo.getPortShort());
16551655
else
16561656
pstmt.setNull(idx++, java.sql.Types.SMALLINT);
16571657
pstmt.setString(idx++, dbinfo.getDatabaseName());
16581658
pstmt.setString(idx++, dbinfo.isUseTunneling()?"1":"0");
16591659
pstmt.setString(idx++, dbinfo.getLocalHostName());
1660-
if(dbinfo.getLocalPortShort()>0)
1660+
if(dbinfo.getLocalPortShort() != 0)
16611661
pstmt.setShort(idx++, dbinfo.getLocalPortShort());
16621662
else
16631663
pstmt.setNull(idx++, java.sql.Types.SMALLINT);
@@ -2012,7 +2012,7 @@ public void upsertDBInfo(DBInstanceInfo dbinfo)
20122012
int idx = 1;
20132013
pstmt.setString(idx++, dbinfo.getDbType());
20142014
pstmt.setString(idx++, String.valueOf(dbinfo.getInstance()));
2015-
if(dbinfo.getPortShort()>0)
2015+
if(dbinfo.getPortShort() != 0)
20162016
pstmt.setShort(idx++, dbinfo.getPortShort());
20172017
else pstmt.setNull(idx++, java.sql.Types.SMALLINT);
20182018
pstmt.setString(idx++, dbinfo.getDatabaseName());
@@ -2021,7 +2021,7 @@ public void upsertDBInfo(DBInstanceInfo dbinfo)
20212021
pstmt.setString(idx++, dbinfo.getLocalHostName().toLowerCase());
20222022
else
20232023
pstmt.setNull(idx++, java.sql.Types.VARCHAR);
2024-
if(dbinfo.getLocalPortShort()>0)
2024+
if(dbinfo.getLocalPortShort() != 0)
20252025
pstmt.setShort(idx++, dbinfo.getLocalPortShort());
20262026
else
20272027
pstmt.setNull(idx++, java.sql.Types.SMALLINT);

myperf/src/main/java/com/yahoo/dba/perf/myperf/springmvc/DbsearchController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ protected ModelAndView handleRequestImpl(HttpServletRequest req,
3535
desc.addColumn("DBTYPE", false, idx++);
3636
desc.addColumn("DBGROUPNAME", false, idx++);
3737
desc.addColumn("HOSTNAME", false, idx++);
38+
desc.addColumn("PORT", false, idx++);
3839
desc.addColumn("DATABASENAME", false, idx++);
3940

4041
for(DBInstanceInfo urp:dbList)
@@ -46,6 +47,7 @@ protected ModelAndView handleRequestImpl(HttpServletRequest req,
4647
cols.add(urp.getDbType());
4748
cols.add(urp.getDbGroupName());
4849
cols.add(urp.getHostName());
50+
cols.add(urp.getPort());
4951
cols.add(urp.getDatabaseName());
5052
rList.addRow(row);
5153
}

myperf/src/main/webapp/WEB-INF/jsp/dbinfo.jsp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ var DBList=[""
6363
<tr id="tr_clusterName">
6464
<td><label for="dbGroupName">Group Name</label></td>
6565
<td><input type="text" id="dbGroupName" name="dbGroupName" autofocus required title="A unique name to identify your standalone database server or a group of servers"/> &nbsp;
66-
<input type="button" value="Find" onclick="prepareDBSearch('dbGroupName','hostName', mydomval('dbGroupName'));" title="Click to find database servers by keyword"/></td>
66+
<input type="button" value="Find" onclick="prepareDBSearch('dbGroupName','hostName', mydomval('dbGroupName'), null, 'port');" title="Click to find database servers by keyword"/></td>
6767
</tr>
6868
<tr id="tr_hostName">
6969
<td><label for="hostName">Host Name</label></td>

myperf/src/main/webapp/WEB-INF/jsp/dbsearch.jsp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@
2020
<script language="javascript">
2121
var target_list_id = null;
2222
var target_host_name = null;
23+
var target_port = null;
2324
function hideDBSearch()
2425
{
2526
mydom("simple_dbsearch").style.display="none";
2627
}
27-
function prepareDBSearch(targetListId, targetHostName, keyword, actWhenOpen)
28+
function prepareDBSearch(targetListId, targetHostName, keyword, actWhenOpen, targetPort)
2829
{
2930
target_list_id = targetListId;
3031
target_host_name = targetHostName;
32+
target_port = targetPort;
3133
if(keyword!=null)
3234
{
3335
mydom("dbsearch_keyword").value=keyword;
@@ -53,6 +55,7 @@
5355
if(obj == null || obj.datatable == null)return;
5456
var dbname = obj.datatable.getCellValueByColumnName(obj.row, 'DBGROUPNAME');
5557
var hostname = obj.datatable.getCellValueByColumnName(obj.row, 'HOSTNAME');
58+
var port = obj.datatable.getCellValueByColumnName(obj.row, 'PORT');
5659
if(target_list_id!=null && mydom(target_list_id)!=null)
5760
{
5861
var l = mydom(target_list_id);
@@ -62,6 +65,8 @@
6265
l.focus();
6366
if(target_host_name!=null && mydom(target_host_name)!=null)
6467
mydom(target_host_name).value=hostname;
68+
if(target_port!=null && mydom(target_port)!=null)
69+
mydom(target_port).value=port;
6570
}
6671
else
6772
{

0 commit comments

Comments
 (0)