Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added query time for action on CF and KS

  • Loading branch information...
commit 97bdca6deae58c357664236fcff9de4ad5c8078e 1 parent 0716e8b
@sebgiroux authored
View
25 columnfamily_action.php
@@ -64,9 +64,11 @@
}
try {
+ $time_start = microtime(true);
$sys_manager->alter_column_family($keyspace_name, $columnfamily_name, $attrs);
+ $time_end = microtime(true);
- $vw_vars['success_message'] = displaySuccessMessage('edit_columnfamily',array('columnfamily_name' => $columnfamily_name));
+ $vw_vars['success_message'] = displaySuccessMessage('edit_columnfamily',array('columnfamily_name' => $columnfamily_name,'query_time' => getQueryTime($time_start,$time_end)));
}
catch(Exception $e) {
$vw_vars['error_message'] = displayErrorMessage('edit_columnfamily',array('columnfamily_name' => $columnfamily_name,'message' => $e->getMessage()));
@@ -183,8 +185,11 @@
$index_name = $_POST['index_name'];
try {
- $sys_manager->create_index($keyspace_name,$columnfamily_name,$column_name,$data_type,$index_name,IndexType::KEYS);
- $vw_vars['success_message'] = displaySuccessMessage('create_secondary_index',array('column_name' => $column_name));
+ $time_start = microtime(true);
+ $sys_manager->create_index($keyspace_name,$columnfamily_name,$column_name,$data_type,$index_name,IndexType::KEYS);
+ $time_end = microtime(true);
+
+ $vw_vars['success_message'] = displaySuccessMessage('create_secondary_index',array('column_name' => $column_name,'query_time' => getQueryTime($time_start,$time_end)));
}
catch (Exception $e) {
$vw_vars['error_message'] = displayErrorMessage('create_secondary_index',array('column_name' => $column_name,'message' => $e->getMessage()));
@@ -251,7 +256,9 @@
$vw_vars['results'] = '';
+ $time_start = microtime(true);
$output = $column_family->get($key);
+ $time_end = microtime(true);
$vw_row_vars['key'] = $key;
$vw_row_vars['value'] = $output;
@@ -267,7 +274,7 @@
$vw_vars['results'] = getHTML('columnfamily_browse_data_row.php',$vw_row_vars);
- $vw_vars['success_message'] = displaySuccessMessage('get_key',array('key' => $key));
+ $vw_vars['success_message'] = displaySuccessMessage('get_key',array('key' => $key, 'query_time' => getQueryTime($time_start,$time_end)));
}
catch (cassandra_NotFoundException $e) {
$vw_vars['success_message'] = displayInfoMessage('get_key_doesnt_exists',array('key' => $key));
@@ -340,7 +347,9 @@
$index_clause = CassandraUtil::create_index_clause($arr_index_expression,'',$nb_rows);
+ $time_start = microtime(true);
$result = $column_family->get_indexed_slices($index_clause);
+ $time_end = microtime(true);
$vw_row_vars['is_super_cf'] = $column_family->cfdef->column_type == 'Super';
$vw_row_vars['is_counter_column'] = $column_family->cfdef->default_validation_class == 'org.apache.cassandra.db.marshal.CounterColumnType';
@@ -364,7 +373,7 @@
$nb_results++;
}
- $vw_vars['error_message_secondary_index'] = displaySuccessMessage('query_secondary_index',array('nb_results' => $nb_results));
+ $vw_vars['error_message_secondary_index'] = displaySuccessMessage('query_secondary_index',array('nb_results' => $nb_results,'query_time' => getQueryTime($time_start,$time_end)));
}
catch (Exception $e) {
$vw_vars['error_message_secondary_index'] = displayErrorMessage('query_secondary_index',array('message' => $e->getMessage()));
@@ -482,15 +491,17 @@
$column_family->remove($key);
}
+ $time_start = microtime(true);
$column_family->insert($key,$data);
+ $time_end = microtime(true);
// Insert successful
if (isset($_POST['mode']) && $_POST['mode'] == 'insert') {
- $vw_vars['success_message'] = displaySuccessMessage('insert_row');
+ $vw_vars['success_message'] = displaySuccessMessage('insert_row',array('query_time' => getQueryTime($time_start,$time_end)));
}
// Edit successful
else {
- $vw_vars['success_message'] = displaySuccessMessage('edit_row',array('key' => $key));
+ $vw_vars['success_message'] = displaySuccessMessage('edit_row',array('key' => $key,'query_time' => getQueryTime($time_start,$time_end)));
}
}
// Some fields are not filled
View
3  describe_keyspace.php
@@ -40,7 +40,8 @@
$vw_vars['added_cf'] = '';
if (isset($_GET['create_cf']) == 1) {
$columnfamily_name = $_SESSION['message'];
- $vw_vars['added_cf'] = displaySuccessMessage('create_columnfamily',array('columnfamily_name' => $columnfamily_name));
+ $query_time = $_SESSION['query_time'];
+ $vw_vars['added_cf'] = displaySuccessMessage('create_columnfamily',array('columnfamily_name' => $columnfamily_name,'query_time' => $query_time));
}
// CF deleted successfully
View
24 include/kernel.inc.php
@@ -66,34 +66,34 @@ function redirect($url) {
function displaySuccessMessage($index,$params = array()) {
if ($index == 'create_keyspace') {
- $return = 'Keyspace '.$params['keyspace_name'].' has been created successfully!';
+ $return = 'Keyspace '.$params['keyspace_name'].' has been created successfully!<br />Query took '.$params['query_time'];
}
elseif ($index == 'edit_keyspace') {
- $return = 'Keyspace '.$params['keyspace_name'].' has been edited successfully!';
+ $return = 'Keyspace '.$params['keyspace_name'].' has been edited successfully!<br />Query took '.$params['query_time'];
}
elseif ($index == 'drop_keyspace') {
- $return = 'Keyspace '.$params['keyspace_name'].' has been dropped successfully!';
+ $return = 'Keyspace '.$params['keyspace_name'].' has been dropped successfully!<br />Query took '.$params['query_time'];
}
elseif ($index == 'create_columnfamily') {
- $return = 'Column family '.$params['columnfamily_name'].' has been created successfully!';
+ $return = 'Column family '.$params['columnfamily_name'].' has been created successfully!<br />Query took '.$params['query_time'];
}
elseif ($index == 'edit_columnfamily') {
- $return = 'Column family '.$params['columnfamily_name'].' has been edited successfully!';
+ $return = 'Column family '.$params['columnfamily_name'].' has been edited successfully!<br />Query took '.$params['query_time'];
}
elseif ($index == 'drop_columnfamily') {
$return = 'Column family dropped successfully!';
}
elseif ($index == 'get_key') {
- $return = 'Successfully got key "'.$params['key'].'"';
+ $return = 'Successfully got key "'.$params['key'].'"<br />Query took '.$params['query_time'];
}
elseif ($index == 'create_secondary_index') {
- $return = 'Secondary index on column '.$params['column_name'].' has been created succesfully!';
+ $return = 'Secondary index on column '.$params['column_name'].' has been created succesfully!<br />Query took '.$params['query_time'];
}
elseif ($index == 'insert_row') {
- $return = 'Row inserted successfully!';
+ $return = 'Row inserted successfully!<br />Query took '.$params['query_time'];
}
elseif ($index == 'edit_row') {
- $return = 'Row "'.$params['key'].'" edited successfully!';
+ $return = 'Row "'.$params['key'].'" edited successfully!<br />Query took '.$params['query_time'];
}
elseif ($index == 'edit_counter') {
$return = 'Counter row edited successfully. Value is now '.$params['value'].'!';
@@ -120,7 +120,7 @@ function displaySuccessMessage($index,$params = array()) {
$return = 'Estimate keys was invoked succesfully! Estimated keys value is : '.$params['nb_keys'];
}
elseif ($index == 'query_secondary_index') {
- $return = 'Successfully got '.$params['nb_results'].' rows from secondary index';
+ $return = 'Successfully got '.$params['nb_results'].' rows from secondary index<br />Query took '.$params['query_time'];
}
return '<div class="success_message">'.$return.'</div>';
@@ -239,4 +239,8 @@ function getPageTitle() {
return $current_page_title;
}
+
+ function getQueryTime($time_start,$time_end) {
+ return round($time_end - $time_start,4).'sec';
+ }
?>
View
5 index.php
@@ -24,7 +24,10 @@
$success_message = $_GET['success_message'];
if ($success_message == 'drop_keyspace') {
- $vw_vars['success_message'] = displaySuccessMessage('drop_keyspace',array('keyspace_name' => $_SESSION['keyspace_name']));
+ $keyspace_name = $_SESSION['keyspace_name'];
+ $query_time = $_SESSION['query_time'];
+
+ $vw_vars['success_message'] = displaySuccessMessage('drop_keyspace',array('keyspace_name' => $keyspace_name,'query_time' => $query_time));
}
}
View
15 keyspace_action.php
@@ -84,9 +84,12 @@
if (!empty($max_compaction_threshold)) $attrs['max_compaction_threshold'] = $max_compaction_threshold;
try {
+ $time_start = microtime(true);
$sys_manager->create_column_family($keyspace_name, $columnfamily_name, $attrs);
+ $time_end = microtime(true);
$_SESSION['message'] = $columnfamily_name;
+ $_SESSION['query_time'] = getQueryTime($time_start,$time_end);
redirect('describe_keyspace.php?keyspace_name='.$keyspace_name.'&create_cf=1');
}
@@ -154,9 +157,11 @@
$attrs = array('replication_factor' => $replication_factor,'strategy_class' => $strategy);
try {
+ $time_start = microtime(true);
$sys_manager->create_keyspace($keyspace_name, $attrs);
+ $time_end = microtime(true);
- $vw_vars['success_message'] = displaySuccessMessage('create_keyspace',array('keyspace_name' => $keyspace_name));
+ $vw_vars['success_message'] = displaySuccessMessage('create_keyspace',array('keyspace_name' => $keyspace_name,'query_time' => getQueryTime($time_start,$time_end)));
}
catch (Exception $e) {
$vw_vars['error_message'] = displayErrorMessage('create_keyspace',array('keyspace_name' => $keyspace_name,'message' => $e->getMessage()));
@@ -201,9 +206,11 @@
$describe_keyspace = $sys_manager->describe_keyspace($keyspace_name);
try {
+ $time_start = microtime(true);
$sys_manager->alter_keyspace($keyspace_name, $attrs);
+ $time_end = microtime(true);
- $vw_vars['success_message'] = displaySuccessMessage('edit_keyspace',array('keyspace_name' => $keyspace_name));
+ $vw_vars['success_message'] = displaySuccessMessage('edit_keyspace',array('keyspace_name' => $keyspace_name,'query_time' => getQueryTime($time_start,$time_end)));
$old_replication_factor = $describe_keyspace->replication_factor;
$new_replication_factor = $replication_factor;
@@ -288,9 +295,13 @@
}
try {
+ $time_start = microtime(true);
$sys_manager->drop_keyspace($keyspace_name);
+ $time_end = microtime(true);
+
$_SESSION['success_message'] = 'drop_keyspace';
$_SESSION['keyspace_name'] = $keyspace_name;
+ $_SESSION['query_time'] = getQueryTime($time_start,$time_end);
redirect('index.php?success_message=drop_keyspace');
}
Please sign in to comment.
Something went wrong with that request. Please try again.