Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
dcdb
dcdb
Commits
31db7e35
Commit
31db7e35
authored
Aug 10, 2020
by
Michael Ott
Browse files
Remove dcdbquerysum tool
parent
47ce8bf6
Changes
2
Hide whitespace changes
Inline
Side-by-side
tools/dcdbquerysum/Makefile
deleted
100644 → 0
View file @
47ce8bf6
include
../../config.mk
CXXFLAGS
+=
-I
../../common/include/
-I
../../lib/include
-I
$(DCDBDEPLOYPATH)
/include
OBJS
=
dcdbquerysum.o
LIBS
=
-L
../../lib
-L
$(DCDBDEPLOYPATH)
/lib
-ldcdb
-lcassandra
-luv
-lboost_random
-lboost_system
-lboost_date_time
-lboost_regex
-lssl
-lcrypto
-lpthread
TARGET
=
dcdbquerysum
.PHONY
:
clean install
$(TARGET)
:
$(OBJS)
$(CXX)
-o
$(TARGET)
$(OBJS)
$(LIBS)
all
:
$(TARGET)
clean
:
rm
-f
$(TARGET)
rm
-f
$(OBJS)
install
:
$(TARGET)
install
$(TARGET)
$(DCDBDEPLOYPATH)
/bin/
tools/dcdbquerysum/dcdbquerysum.cpp
deleted
100644 → 0
View file @
47ce8bf6
//================================================================================
// Name : dcdbquerysum.cpp
// Author : Axel Auweter
// Contact : info@dcdb.it
// Copyright : Leibniz Supercomputing Centre
// Description : Command line utility for testing the dcdbquerysum implementation
//================================================================================
//================================================================================
// This file is part of DCDB (DataCenter DataBase)
// Copyright (C) 2011-2019 Leibniz Supercomputing Centre
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//================================================================================
/* C++ standard headers */
#include <list>
#include <iostream>
#include <stdexcept>
/* C standard headers */
#include <cstdlib>
#include <ctime>
#include <cstdint>
#include <unistd.h>
/* Custom headers */
#include "dcdb/timestamp.h"
#include "dcdb/c_api.h"
#include "dcdb/version.h"
#include "version.h"
void
usage
()
{
std
::
cout
<<
"Usage: dcdbquerysum [-h <hostname>] [-l] <sensor 1> [<sensor 2> ...] <start> <end>"
<<
std
::
endl
<<
" with <hostname> - host name of database host"
<<
std
::
endl
<<
" -l - interpret <start>, <end> as local time instead of utc"
<<
std
::
endl
<<
" <sensor n> - public name of sensor"
<<
std
::
endl
<<
" <start> - interval start time"
<<
std
::
endl
<<
" <end> - interval end time"
<<
std
::
endl
<<
std
::
endl
<<
" Start and end times may be specified in the same forms as in dcdbquery."
<<
std
::
endl
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
std
::
cout
<<
"dcdbquerysum "
<<
VERSION
<<
" (libdcdb "
<<
DCDB
::
Version
::
getVersion
()
<<
")"
<<
std
::
endl
<<
std
::
endl
;
/* Check command line arguments */
if
(
argc
<=
3
)
{
usage
();
exit
(
EXIT_FAILURE
);
}
/* Get the options */
int
ret
;
const
char
*
host
=
getenv
(
"DCDB_HOSTNAME"
);
bool
localtime
=
false
;
if
(
!
host
)
{
host
=
"localhost"
;
}
while
((
ret
=
getopt
(
argc
,
argv
,
"+h:l"
))
!=-
1
)
{
switch
(
ret
)
{
case
'h'
:
host
=
optarg
;
break
;
case
'l'
:
localtime
=
true
;
break
;
default:
usage
();
exit
(
EXIT_FAILURE
);
}
}
/* Try to create TimeStamp objects from the arguments */
DCDB
::
TimeStamp
start
,
end
;
try
{
start
=
DCDB
::
TimeStamp
(
argv
[
argc
-
2
],
localtime
);
end
=
DCDB
::
TimeStamp
(
argv
[
argc
-
1
],
localtime
);
}
catch
(
std
::
exception
&
e
)
{
std
::
cout
<<
"Wrong time format."
<<
std
::
endl
;
exit
(
EXIT_FAILURE
);
}
/* Ensure start < end */
if
(
start
>=
end
)
{
std
::
cout
<<
"Start time must be earlier than end time."
<<
std
::
endl
;
exit
(
EXIT_FAILURE
);
}
/* Build a list of sensor names */
std
::
list
<
std
::
string
>
sensors
;
for
(
int
arg
=
optind
;
arg
<
argc
-
2
;
arg
++
)
{
sensors
.
push_back
(
argv
[
arg
]);
}
/* Since we want to test the C API, we now have to convert all the lovely C++ data structures into C */
/* TimeStamp -> time_t (TODO: this should be implemented in DCDBLib) */
//std::cout << "Start: " << start.getString() << std::endl;
//std::cout << "End: " << end.getString() << std::endl;
struct
tm
tstart
=
{},
tend
=
{};
time_t
cstart
,
cend
;
// mktime() expects local time, so let's convert it
start
.
convertToLocal
();
end
.
convertToLocal
();
/* Format is 2016-01-14T09:41:06.455049000 */
strptime
(
start
.
getString
().
c_str
(),
"%Y-%m-%dT%T"
,
&
tstart
);
strptime
(
end
.
getString
().
c_str
(),
"%Y-%m-%dT%T"
,
&
tend
);
cstart
=
mktime
(
&
tstart
);
cend
=
mktime
(
&
tend
);
/* std::list<std::string> sensors -> const char* csensors[] */
const
char
**
csensors
=
(
const
char
**
)
calloc
(
sensors
.
size
(),
sizeof
(
char
*
));
int
i
=
0
;
for
(
std
::
list
<
std
::
string
>::
iterator
it
=
sensors
.
begin
();
it
!=
sensors
.
end
();
it
++
)
{
csensors
[
i
]
=
it
->
c_str
();
i
++
;
}
/* Call the C API Query Sum Multiple */
int64_t
result
;
switch
(
dcdbQuerySumMultipleThreaded
(
&
result
,
/* Here goes the intgrated result */
host
,
/* Database host name */
9042
,
/* Cassandra CQL Port */
csensors
,
/* Pointer to sensor name array */
sensors
.
size
(),
/* Length of csensors array */
cstart
,
/* Start time */
cend
,
/* End time */
0
,
/* No special options */
4
/* Use 4 threads */
))
{
case
DCDB_C_OK
:
std
::
cout
<<
result
<<
std
::
endl
;
break
;
case
DCDB_C_CONNERR
:
std
::
cerr
<<
"Error: Cannot connect to data base."
<<
std
::
endl
;
break
;
case
DCDB_C_SENSORNOTFOUND
:
std
::
cerr
<<
"Error: One or more sensors not found."
<<
std
::
endl
;
break
;
case
DCDB_C_EMPTYSET
:
std
::
cerr
<<
"Error: Empty set."
<<
std
::
endl
;
break
;
case
DCDB_C_NOTINTEGRABLE
:
std
::
cerr
<<
"Error: One or more sensors are marked non-integrable."
<<
std
::
endl
;
break
;
case
DCDB_C_BADPARAMS
:
case
DCDB_C_NOSENSOR
:
case
DCDB_C_UNKNOWN
:
std
::
cerr
<<
"Error: Unknown error."
<<
std
::
endl
;
break
;
}
/* Clean up */
free
(
csensors
);
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment