From 3815f11a276e115c5fb522269d7096d7ed9c73d1 Mon Sep 17 00:00:00 2001 From: FlashySearch Date: Wed, 26 Dec 2012 22:56:42 +0100 Subject: [PATCH 01/17] You can save values like 0 now. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue #20 https://github.com/sebgiroux/Cassandra-Cluster-Admin/issues/20 --- columnfamily_action.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/columnfamily_action.php b/columnfamily_action.php index 672862b..1d628cf 100644 --- a/columnfamily_action.php +++ b/columnfamily_action.php @@ -550,7 +550,7 @@ $column_name = $_POST['column_name_'.$no_scf.'_'.$no_column]; $column_value = $_POST['column_value_'.$no_scf.'_'.$no_column]; - if (!empty($_POST['column_name_'.$no_scf.'_'.$no_column]) && !empty($_POST['column_value_'.$no_scf.'_'.$no_column])) { + if ($_POST['column_name_'.$no_scf.'_'.$no_column] != '' && $_POST['column_value_'.$no_scf.'_'.$no_column] != '') { // CF if ($column_key_name == '') { $data[$column_name] = $column_value; @@ -1034,4 +1034,4 @@ } echo getHTML('footer.php'); -?> \ No newline at end of file +?> From 9edbb0aeaadd629270ab2c975c6f4880b6994ef4 Mon Sep 17 00:00:00 2001 From: FlashySearch Date: Wed, 26 Dec 2012 22:57:30 +0100 Subject: [PATCH 02/17] Removed obsolete ?nav=schema --- views/cluster_info.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/views/cluster_info.php b/views/cluster_info.php index 99bfea6..ad1807a 100644 --- a/views/cluster_info.php +++ b/views/cluster_info.php @@ -1,6 +1,6 @@ - + @@ -9,7 +9,7 @@
@@ -106,4 +106,3 @@ - From 1399a66b2aea1f28859d5a8aff1fabc65ca91670 Mon Sep 17 00:00:00 2001 From: FlashySearch Date: Wed, 26 Dec 2012 23:26:48 +0100 Subject: [PATCH 03/17] Updated outdated screenshots @sebgiroux: Feel free to download the screenshots and upload them on your servers, if you want to. --- README.mkd | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.mkd b/README.mkd index 8d2f0ee..1d00919 100644 --- a/README.mkd +++ b/README.mkd @@ -13,6 +13,8 @@ Screenshots [![Cassandra Cluster Admin Homepage](http://img708.imageshack.us/img708/7939/screenshot1kk.th.png)](http://img708.imageshack.us/img708/7939/screenshot1kk.png) [![Cassandra Cluster Admin Column family Definition and Actions](http://img24.imageshack.us/img24/7249/screenshot2po.th.png)](http://img24.imageshack.us/img24/7249/screenshot2po.png) [![Cassandra Cluster Admin List of Column Families in a Keyspace](http://img855.imageshack.us/img855/3512/screenshot3tc.th.png)](http://img855.imageshack.us/img855/3512/screenshot3tc.png) [![Cassandra Cluster Admin Edit a Column Family](http://img52.imageshack.us/img52/6885/screenshot4kr.th.png)](http://img52.imageshack.us/img52/6885/screenshot4kr.png) +[![Viewing Keyspaces and Column Families](http://www.flashy.cc/cassandra-cluster-admin/1.png)](http://www.flashy.cc/cassandra-cluster-admin/1.png) [![Viewing Cluster](http://www.flashy.cc/cassandra-cluster-admin/2.png)](http://www.flashy.cc/cassandra-cluster-admin/2.png) [![Cassandra Cluster Admin Column family Definition and Actions](http://www.flashy.cc/cassandra-cluster-admin/4.png)](http://www.flashy.cc/cassandra-cluster-admin/4.png) [![Cassandra Cluster Admin List of Column Families in a Keyspace](http://www.flashy.cc/cassandra-cluster-admin/5.png)](http://www.flashy.cc/cassandra-cluster-admin/5.png) + Supported actions ------------------------------------------------ * Keyspace manipulation (add/edit/drop) @@ -64,4 +66,4 @@ Credits ------------------------------------------------ * The Apache Cassandra project - http://cassandra.apache.org/ * Tyler Hobbs (thobbs) - phpcassa - https://github.com/thobbs/phpcassa -* Twitter Bootstrap - https://github.com/twitter/bootstrap/ \ No newline at end of file +* Twitter Bootstrap - https://github.com/twitter/bootstrap/ From c3fa1caa21f79ae6e164f0939c02d056704f5195 Mon Sep 17 00:00:00 2001 From: FlashySearch Date: Wed, 26 Dec 2012 23:41:12 +0100 Subject: [PATCH 04/17] Update README.mkd --- README.mkd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.mkd b/README.mkd index 1d00919..0e2190b 100644 --- a/README.mkd +++ b/README.mkd @@ -13,7 +13,7 @@ Screenshots [![Cassandra Cluster Admin Homepage](http://img708.imageshack.us/img708/7939/screenshot1kk.th.png)](http://img708.imageshack.us/img708/7939/screenshot1kk.png) [![Cassandra Cluster Admin Column family Definition and Actions](http://img24.imageshack.us/img24/7249/screenshot2po.th.png)](http://img24.imageshack.us/img24/7249/screenshot2po.png) [![Cassandra Cluster Admin List of Column Families in a Keyspace](http://img855.imageshack.us/img855/3512/screenshot3tc.th.png)](http://img855.imageshack.us/img855/3512/screenshot3tc.png) [![Cassandra Cluster Admin Edit a Column Family](http://img52.imageshack.us/img52/6885/screenshot4kr.th.png)](http://img52.imageshack.us/img52/6885/screenshot4kr.png) -[![Viewing Keyspaces and Column Families](http://www.flashy.cc/cassandra-cluster-admin/1.png)](http://www.flashy.cc/cassandra-cluster-admin/1.png) [![Viewing Cluster](http://www.flashy.cc/cassandra-cluster-admin/2.png)](http://www.flashy.cc/cassandra-cluster-admin/2.png) [![Cassandra Cluster Admin Column family Definition and Actions](http://www.flashy.cc/cassandra-cluster-admin/4.png)](http://www.flashy.cc/cassandra-cluster-admin/4.png) [![Cassandra Cluster Admin List of Column Families in a Keyspace](http://www.flashy.cc/cassandra-cluster-admin/5.png)](http://www.flashy.cc/cassandra-cluster-admin/5.png) +[![Viewing Keyspaces and Column Families](http://www.flashy.cc/cassandra-cluster-admin/1_small.png)](http://www.flashy.cc/cassandra-cluster-admin/1.png) [![Viewing Cluster](http://www.flashy.cc/cassandra-cluster-admin/2_small.png)](http://www.flashy.cc/cassandra-cluster-admin/2.png) [![Cassandra Cluster Admin Column family Definition and Actions](http://www.flashy.cc/cassandra-cluster-admin/4_small.png)](http://www.flashy.cc/cassandra-cluster-admin/4.png) [![Cassandra Cluster Admin List of Column Families in a Keyspace](http://www.flashy.cc/cassandra-cluster-admin/5_small.png)](http://www.flashy.cc/cassandra-cluster-admin/5.png) Supported actions ------------------------------------------------ From 7e99200a3c9f277961d6941c0c7054012ddcc27e Mon Sep 17 00:00:00 2001 From: FlashySearch Date: Wed, 26 Dec 2012 23:41:25 +0100 Subject: [PATCH 05/17] Update README.mkd --- README.mkd | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.mkd b/README.mkd index 0e2190b..fcd2bd8 100644 --- a/README.mkd +++ b/README.mkd @@ -11,8 +11,6 @@ Bug report and/or pull request are always welcome! Screenshots ------------------------------------------------ -[![Cassandra Cluster Admin Homepage](http://img708.imageshack.us/img708/7939/screenshot1kk.th.png)](http://img708.imageshack.us/img708/7939/screenshot1kk.png) [![Cassandra Cluster Admin Column family Definition and Actions](http://img24.imageshack.us/img24/7249/screenshot2po.th.png)](http://img24.imageshack.us/img24/7249/screenshot2po.png) [![Cassandra Cluster Admin List of Column Families in a Keyspace](http://img855.imageshack.us/img855/3512/screenshot3tc.th.png)](http://img855.imageshack.us/img855/3512/screenshot3tc.png) [![Cassandra Cluster Admin Edit a Column Family](http://img52.imageshack.us/img52/6885/screenshot4kr.th.png)](http://img52.imageshack.us/img52/6885/screenshot4kr.png) - [![Viewing Keyspaces and Column Families](http://www.flashy.cc/cassandra-cluster-admin/1_small.png)](http://www.flashy.cc/cassandra-cluster-admin/1.png) [![Viewing Cluster](http://www.flashy.cc/cassandra-cluster-admin/2_small.png)](http://www.flashy.cc/cassandra-cluster-admin/2.png) [![Cassandra Cluster Admin Column family Definition and Actions](http://www.flashy.cc/cassandra-cluster-admin/4_small.png)](http://www.flashy.cc/cassandra-cluster-admin/4.png) [![Cassandra Cluster Admin List of Column Families in a Keyspace](http://www.flashy.cc/cassandra-cluster-admin/5_small.png)](http://www.flashy.cc/cassandra-cluster-admin/5.png) Supported actions From 84864a8100f8adb1167d0ab42b64b24a5f2080c5 Mon Sep 17 00:00:00 2001 From: FlashySearch Date: Thu, 27 Dec 2012 00:07:49 +0100 Subject: [PATCH 06/17] Updated outdated screenshots --- README.mkd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.mkd b/README.mkd index fcd2bd8..7577b88 100644 --- a/README.mkd +++ b/README.mkd @@ -4,7 +4,7 @@ Cassandra Cluster Admin is a GUI tool to help people administrate their Apache C If you're like me and used MySQL for a while (and still using it!), you get used to phpMyAdmin and its simple and easy to use user interface. I thought it would be nice to have a similar tool for Cassandra and I couldn't find any, so I build my own! -With Cassandra Cluster Admin, you can create/edit/drop keyspace and column family, truncate a column family, create secondary indexes, display a row, browse data (get range slice), insert a row and much more! +With Cassandra Cluster Admin, you can create/edit/drop keyspaces and column families, truncate a column family, create secondary indexes, display a row, browse data (get range slice), insert a row and much more! Bug report and/or pull request are always welcome! @@ -57,7 +57,7 @@ Add the following line to your php.ini file: Disclaimer ------------------------------------------------ -This software is still in beta so always be careful when using it on a production cluster. I won't take any responsability if for some reason this tool drop all your keyspaces and wipe all your data, althought I really doubt it will happen =) +This software is still in beta so always be careful when using it on a production cluster. I won't take any responsability if for some reason this tool drops all your keyspaces and wipes all your data, although I really doubt it will happen =) Credits From 1532bb74ad9f1ac4ff074fa9bf61bdb372444598 Mon Sep 17 00:00:00 2001 From: FlashySearch Date: Thu, 27 Dec 2012 01:34:19 +0100 Subject: [PATCH 07/17] Update views/cluster_info.php --- views/cluster_info.php | 1125 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 1027 insertions(+), 98 deletions(-) diff --git a/views/cluster_info.php b/views/cluster_info.php index ad1807a..1d628cf 100644 --- a/views/cluster_info.php +++ b/views/cluster_info.php @@ -1,108 +1,1037 @@ - - - - - - - - - - - -
- -
- Cluster Name: - -
- - Cluster Partitioner:
- Cluster Snitch:
- Thrift API Version:

- Schema Versions:
- - $servers): - foreach ($servers as $server): - echo ''; - if ($version == 'UNREACHABLE'): - echo ''; - else: - echo ''; - endif; - echo ''; - endforeach; - endforeach; - ?> -
×'.$server.''.$version.''.$server.''.$version.'
-
- - + /* + Cassandra Cluster Admin + + @author Sébastien Giroux + @copyright All rights reserved - 2011 + */ -
    -

    Keyspaces and Column Families

    - - Create New Keyspace - -

    - - - '; - $beg .= ''; - $end .= ''; - elseif ($i/2 == intval($i/2)): - $beg = ''; - else: - $beg = ''; - $end .= ''; - endif; + $output = $column_family->get_range($offset_key,'',$nb_rows,null); + + $vw_vars['results'] = ''; + $nb_results = 0; + + foreach ($output as $key => $value) { + $vw_row_vars['key'] = $key; + $vw_row_vars['value'] = $value; + + $vw_row_vars['keyspace_name'] = $keyspace_name; + $vw_row_vars['columnfamily_name'] = $columnfamily_name; + + $vw_row_vars['show_actions_link'] = true; + + $vw_vars['results'] .= getHTML('columnfamily_browse_data_row.php',$vw_row_vars); + + $nb_results++; + } + + $vw_vars['show_begin_page_link'] = $offset_key != ''; + $vw_vars['show_prev_page_link'] = $offset_key != '' && count($_SESSION['browse_data_offset_key']) > 0; + + // We got the number of rows we asked for, display "Next Page" link + if ($nb_results == $nb_rows) { + $offset_key = ++$key; + + $vw_vars['offset_key'] = $offset_key; + $vw_vars['show_next_page_link'] = true; + } + else { + $vw_vars['offset_key'] = ''; + $vw_vars['show_next_page_link'] = false; + } + + $current_page_title = 'Cassandra Cluster Admin > '.$keyspace_name.' > '.$columnfamily_name.' > Browse Data'; + + $vw_vars['is_counter_column'] = $vw_row_vars['is_counter_column']; + + echo getHTML('columnfamily_browse_data.php',$vw_vars); + } + catch (cassandra\NotFoundException $e) { + echo displayErrorMessage('columnfamily_doesnt_exists',array('column_name' => $columnfamily_name)); + } + catch (Exception $e) { + echo displayErrorMessage('something_wrong_happened',array('message' => $e->getMessage())); + } + } + + /* + Edit a row + */ + if ($action == 'edit_row') { + $is_valid_action = true; + + $keyspace_name = ''; + if (isset($_GET['keyspace_name'])) { + $keyspace_name = $_GET['keyspace_name']; + } + + $columnfamily_name = ''; + if (isset($_GET['columnfamily_name'])) { + $columnfamily_name = $_GET['columnfamily_name']; + } + + $key = ''; + if (isset($_GET['key'])) { + $key = $_GET['key']; + } + + $super_key = ''; + if (isset($_GET['super_key'])) { + $super_key = $_GET['super_key']; + } + + $vw_vars['cluster_name'] = $sys_manager->describe_cluster_name(); + $vw_vars['keyspace_name'] = $keyspace_name; + $vw_vars['columnfamily_name'] = $columnfamily_name; + + if (!isset($vw_vars['success_message'])) $vw_vars['success_message'] = ''; + if (!isset($vw_vars['info_message'])) $vw_vars['info_message'] = ''; + if (!isset($vw_vars['error_message'])) $vw_vars['error_message'] = ''; + + $cf_def = ColumnFamilyHelper::getCFInKeyspace($keyspace_name,$columnfamily_name); + + $is_super_cf = $cf_def->column_type == 'Super'; + $vw_vars['is_super_cf'] = $cf_def->column_type == 'Super'; + + $vw_vars['key'] = $key; + $vw_vars['super_key'] = $super_key; + + $vw_vars['mode'] = 'edit'; + + try { + $pool = new ConnectionPool($keyspace_name, $cluster_helper->getArrayOfNodesForCurrentCluster(),null,5,5000,5000,10000,$cluster_helper->getCredentialsForCurrentCluster()); + + if ($is_super_cf) { + $column_family = new SuperColumnFamily($pool, $columnfamily_name); + } + else { + $column_family = new ColumnFamily($pool, $columnfamily_name); + } + + $vw_vars['results'] = ''; - echo $beg; + $output = $column_family->get($key); + $vw_vars['output'] = $output; + } + catch (Exception $e) { + echo displayErrorMessage('something_wrong_happened',array('message' => $e->getMessage())); + } + + $current_page_title = 'Cassandra Cluster Admin > '.$keyspace_name.' > '.$columnfamily_name.' > Edit Row'; + + $included_header = true; + echo getHTML('header.php'); + echo getHTML('columnfamily_insert_edit_row.php',$vw_vars); + } + + /* + Delete a row + */ + if ($action == 'delete_row') { + $is_valid_action = true; + + $keyspace_name = ''; + if (isset($_GET['keyspace_name'])) { + $keyspace_name = $_GET['keyspace_name']; + } + + $columnfamily_name = ''; + if (isset($_GET['columnfamily_name'])) { + $columnfamily_name = $_GET['columnfamily_name']; + } + + $key = ''; + if (isset($_GET['key'])) { + $key = $_GET['key']; + } + + $super_column_key = null; + if (isset($_GET['super_column_key'])) { + $super_column_key = $_GET['super_column_key']; + } + + try { + $pool = new ConnectionPool($keyspace_name, $cluster_helper->getArrayOfNodesForCurrentCluster(),null,5,5000,5000,10000,$cluster_helper->getCredentialsForCurrentCluster()); + + $cf_def = ColumnFamilyHelper::getCFInKeyspace($keyspace_name,$columnfamily_name); + $is_super_cf = $cf_def->column_type == 'Super'; + + if ($is_super_cf) { + $column_family = new SuperColumnFamily($pool, $columnfamily_name); + } + else { + $column_family = new ColumnFamily($pool, $columnfamily_name); + } + + $column_family->remove($key,null,$super_column_key); + + redirect('columnfamily_action.php?action=browse_data&keyspace_name='.$keyspace_name.'&columnfamily_name='.$columnfamily_name); + } + catch (cassandra\NotFoundException $e) { + $included_header = true; + echo getHTML('header.php'); + echo displayErrorMessage('columnfamily_doesnt_exists',array('column_name' => $columnfamily_name)); + } + catch (Exception $e) { + $included_header = true; + echo getHTML('header.php'); + echo displayErrorMessage('something_wrong_happened',array('message' => $e->getMessage())); + } + } + + /* + Modify counter + */ + if (isset($_POST['btn_modify_counter'])) { + $is_valid_action = true; + + $key = ''; + if (isset($_POST['key'])) $key = $_POST['key']; + + $super_column = null; + if (isset($_POST['super_column'])) $super_column = $_POST['super_column']; + + $column = ''; + if (isset($_POST['column'])) $column = $_POST['column']; + + $action = ''; + if (isset($_POST['action'])) $action = $_POST['action']; + + $value = ''; + if (isset($_POST['value'])) $value = $_POST['value']; - $keyspace_name = $keyspaces_name[$i]; - - echo '
  • '.$keyspace_name.''; - echo '
      '; - $nb_cf = count($keyspaces_details[$i]['columnfamilies_name']); - for ($j = 0; $j < $nb_cf; $j++): - $columnfamily_name = $keyspaces_details[$i]['columnfamilies_name'][$j]; - echo '
    • '.$columnfamily_name.'
    • '; - endfor; - echo '
    '; - echo '
  • '; + $keyspace_name = ''; + if (isset($_POST['keyspace_name'])) $keyspace_name = $_POST['keyspace_name']; + + $columnfamily_name = ''; + if (isset($_POST['columnfamily_name'])) $columnfamily_name = $_POST['columnfamily_name']; + + try { + $pool = new ConnectionPool($keyspace_name, $cluster_helper->getArrayOfNodesForCurrentCluster(),null,5,5000,5000,10000,$cluster_helper->getCredentialsForCurrentCluster()); + + $cf_def = ColumnFamilyHelper::getCFInKeyspace($keyspace_name,$columnfamily_name); + $is_super_cf = $cf_def->column_type == 'Super'; + + if ($is_super_cf) { + $column_family = new SuperColumnFamily($pool, $columnfamily_name); + } + else { + $column_family = new ColumnFamily($pool, $columnfamily_name); + } + + if ($action == 'dec') { + $value *= -1; + } + + $column_family->add($key, $super_column, $column, $value); + + $new_value = $column_family->get($key); - echo $end; - endfor; - ?> -
    '; + require('include/kernel.inc.php'); + require('include/verify_login.inc.php'); + + use phpcassa\Connection\ConnectionPool; + use phpcassa\ColumnFamily; + use phpcassa\SuperColumnFamily; + use cassandra\IndexType; + + $included_header = false; + $is_valid_action = false; + $action = ''; + if (isset($_GET['action'])) $action = $_GET['action']; + + /* + Submit form edit column family + */ + + if (isset($_POST['btn_edit_columnfamily'])) { + $column_type = $_POST['column_type']; + + $comment = $_POST['comment']; + $row_cache_size = $_POST['row_cache_size']; + $row_cache_save_period_in_seconds = $_POST['row_cache_save_period_in_seconds']; + $key_cache_size = $_POST['key_cache_size']; + $key_cache_save_period_in_seconds = $_POST['key_cache_save_period_in_seconds']; + $read_repair_chance = $_POST['read_repair_chance']; + $gc_grace_seconds = $_POST['gc_grace_seconds']; + + $default_validation_class = $_POST['default_validation_class']; + $min_compaction_threshold = $_POST['min_compaction_threshold']; + $max_compaction_threshold = $_POST['max_compaction_threshold']; + + $keyspace_name = $_POST['keyspace_name']; + $columnfamily_name = $_POST['columnfamily_name']; + + $attrs = array('column_type' => $column_type, + 'comment' => $comment, + 'row_cache_size' => $row_cache_size, + 'row_cache_save_period_in_seconds' => $row_cache_save_period_in_seconds, + 'key_cache_size' => $key_cache_size, + 'key_cache_save_period_in_seconds' => $key_cache_save_period_in_seconds, + 'read_repair_chance' => $read_repair_chance, + 'gc_grace_seconds' => $gc_grace_seconds, + 'default_validation_class' => $default_validation_class, + 'min_compaction_threshold' => $min_compaction_threshold, + 'max_compaction_threshold' => $max_compaction_threshold); + + $thrift_api_version = $sys_manager->describe_version(); + + // Cassandra 0.8- + if (version_compare($thrift_api_version,THRIFT_API_VERSION_FOR_CASSANDRA_1_0,'<')) { + $attrs['memtable_operations_in_millions'] = $_POST['memtable_operations_in_millions']; + $attrs['memtable_throughput_in_mb'] = $_POST['memtable_throughput_in_mb']; + $attrs['memtable_flush_after_mins'] = $_POST['memtable_flush_after_mins']; + } + + // Cassandra 1.0+ + if (version_compare($thrift_api_version,THRIFT_API_VERSION_FOR_CASSANDRA_1_0,'>=')) { + $attrs['replicate_on_write'] = $_POST['replicate_on_write']; + $attrs['key_validation_class'] = $_POST['key_validation_class']; + $attrs['key_alias'] = $_POST['key_alias']; + $attrs['compaction_strategy'] = $_POST['compaction_strategy']; + $attrs['bloom_filter_fp_chance'] = $_POST['bloom_filter_fp_chance']; + $attrs['caching'] = $_POST['caching']; + $attrs['dclocal_read_repair_chance'] = $_POST['dclocal_read_repair_chance']; + $attrs['merge_shards_chance'] = $_POST['merge_shards_chance']; + $attrs['row_cache_provider'] = $_POST['row_cache_provider']; + $attrs['row_cache_keys_to_save'] = $_POST['row_cache_keys_to_save']; + } + + if (isset($_POST['comparator_type'])) + $attrs['comparator_type'] = $_POST['comparator_type']; + + if ($column_type == 'Super' && isset($_POST['subcomparator_type'])) { + $attrs['subcomparator_type'] = $_POST['subcomparator_type']; + } + else { + $attrs['subcomparator_type'] = null; + } + + 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,'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())); + } + } + + /* + Edit a column family + */ + + if ($action == 'edit') { + $is_valid_action = true; + + $keyspace_name = ''; + if (isset($_GET['keyspace_name'])) { + $keyspace_name = $_GET['keyspace_name']; + } + + $columnfamily_name = ''; + if (isset($_GET['columnfamily_name'])) { + $columnfamily_name = $_GET['columnfamily_name']; + } + + $vw_vars['cluster_name'] = $sys_manager->describe_cluster_name(); + $vw_vars['keyspace_name'] = $keyspace_name; + $vw_vars['columnfamily_name'] = $columnfamily_name; + + $cf = ColumnFamilyHelper::getCFInKeyspace($keyspace_name,$columnfamily_name); + + $current_page_title = 'Cassandra Cluster Admin > '.$keyspace_name.' > '.$columnfamily_name.' > Edit Column Family'; + + $included_header = true; + echo getHTML('header.php'); + + if ($cf) { + $vw_vars['column_type'] = $cf->column_type; + $vw_vars['comparator_type'] = $cf->comparator_type; + $vw_vars['subcomparator_type'] = $cf->subcomparator_type; + $vw_vars['comment'] = $cf->comment; + $vw_vars['row_cache_size'] = $cf->row_cache_size; + $vw_vars['key_cache_size'] = $cf->key_cache_size; + $vw_vars['read_repair_chance'] = $cf->read_repair_chance; + $vw_vars['gc_grace_seconds'] = $cf->gc_grace_seconds; + $vw_vars['default_validation_class'] = $cf->default_validation_class; + $vw_vars['id'] = $cf->id; + $vw_vars['min_compaction_threshold'] = $cf->min_compaction_threshold; + $vw_vars['max_compaction_threshold'] = $cf->max_compaction_threshold; + $vw_vars['row_cache_save_period_in_seconds'] = $cf->row_cache_save_period_in_seconds; + $vw_vars['key_cache_save_period_in_seconds'] = $cf->key_cache_save_period_in_seconds; + + $thrift_api_version = $sys_manager->describe_version(); + + // Cassandra 0.8- + if (version_compare($thrift_api_version,THRIFT_API_VERSION_FOR_CASSANDRA_1_0,'<')) { + $vw_vars['memtable_flush_after_mins'] = $cf->memtable_flush_after_mins; + $vw_vars['memtable_throughput_in_mb'] = $cf->memtable_throughput_in_mb; + $vw_vars['memtable_operations_in_millions'] = $cf->memtable_operations_in_millions; + } + + // Cassandra 1.0+ + if (version_compare($thrift_api_version,THRIFT_API_VERSION_FOR_CASSANDRA_1_0,'>=')) { + $vw_vars['replicate_on_write'] = $cf->replicate_on_write; + $vw_vars['key_validation_class'] = $cf->key_validation_class; + $vw_vars['key_alias'] = $cf->key_alias; + $vw_vars['compaction_strategy'] = $cf->compaction_strategy; + $vw_vars['bloom_filter_fp_chance'] = $cf->bloom_filter_fp_chance; + $vw_vars['caching'] = $cf->caching; + $vw_vars['dclocal_read_repair_chance'] = $cf->dclocal_read_repair_chance; + $vw_vars['merge_shards_chance'] = $cf->merge_shards_chance; + $vw_vars['row_cache_provider'] = $cf->row_cache_provider; + $vw_vars['row_cache_keys_to_save'] = $cf->row_cache_keys_to_save; + } + + if (!isset($vw_vars['success_message'])) $vw_vars['success_message'] = ''; + if (!isset($vw_vars['error_message'])) $vw_vars['error_message'] = ''; - $end = '
    '; + $vw_vars['mode'] = 'edit'; + $vw_vars['thrift_api_version'] = $thrift_api_version; + + echo getHTML('create_edit_columnfamily.php',$vw_vars); + } + else { + echo displayErrorMessage('columnfamily_doesnt_exists', array('column_name' => $columnfamily_name)); + } + } + + /* + Drop a column family + */ + + if ($action == 'drop') { + $is_valid_action = true; + + $keyspace_name = ''; + if (isset($_GET['keyspace_name'])) { + $keyspace_name = $_GET['keyspace_name']; + } + + $columnfamily_name = ''; + if (isset($_GET['columnfamily_name'])) { + $columnfamily_name = $_GET['columnfamily_name']; + } + + $current_page_title = 'Cassandra Cluster Admin > '.$keyspace_name.' > '.$columnfamily_name.' > Drop Column Family'; + + try { + $sys_manager->drop_column_family($keyspace_name, $columnfamily_name); + redirect('describe_keyspace.php?keyspace_name='.$keyspace_name.'&deleted_cf=1'); + } + catch (Exception $e) { + $included_header = true; + echo getHTML('header.php'); + echo displayErrorMessage('drop_columnfamily',array('message' => $e->getMessage())); + } + } + + /* + Submit form create a secondary index + */ + + if (isset($_POST['btn_create_secondary_index'])) { + $keyspace_name = ''; + if (isset($_GET['keyspace_name'])) { + $keyspace_name = $_GET['keyspace_name']; + } + + $columnfamily_name = ''; + if (isset($_GET['columnfamily_name'])) { + $columnfamily_name = $_GET['columnfamily_name']; + } - $end = ''; + $column_name = $_POST['column_name']; + $data_type = $_POST['data_type']; + $index_name = $_POST['index_name']; + + try { + $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())); + } + } + + /* + Create a secondary index + */ + + if ($action == 'create_secondary_index') { + $is_valid_action = true; + + $keyspace_name = ''; + if (isset($_GET['keyspace_name'])) { + $keyspace_name = $_GET['keyspace_name']; + } + + $columnfamily_name = ''; + if (isset($_GET['columnfamily_name'])) { + $columnfamily_name = $_GET['columnfamily_name']; + } + + $vw_vars['cluster_name'] = $sys_manager->describe_cluster_name(); + $vw_vars['keyspace_name'] = $keyspace_name; + $vw_vars['columnfamily_name'] = $columnfamily_name; + + $vw_vars['mode'] = 'create'; + + $cf = ColumnFamilyHelper::getCFInKeyspace($keyspace_name,$columnfamily_name); + + if (!isset($vw_vars['success_message'])) $vw_vars['success_message'] = ''; + if (!isset($vw_vars['error_message'])) $vw_vars['error_message'] = ''; + + $included_header = true; + $current_page_title = 'Cassandra Cluster Admin > '.$keyspace_name.' > '.$columnfamily_name.' > Create Secondary Index'; + + echo getHTML('header.php'); + echo getHTML('create_edit_secondary_index.php',$vw_vars); + } + + + /* + Submit form get key + */ + if (isset($_POST['btn_get_key'])) { + $i = 0; + $tab_keys = array(); + while (isset($_POST['key_'.$i])) { + $tab_keys[] = $_POST['key_'.$i]; + $i++; + } + + $keyspace_name = ''; + if (isset($_GET['keyspace_name'])) { + $keyspace_name = $_GET['keyspace_name']; + } + + $columnfamily_name = ''; + if (isset($_GET['columnfamily_name'])) { + $columnfamily_name = $_GET['columnfamily_name']; + } + + $cf_def = ColumnFamilyHelper::getCFInKeyspace($keyspace_name,$columnfamily_name); + $is_super_cf = $cf_def->column_type == 'Super'; + + try { + $pool = new ConnectionPool($keyspace_name, $cluster_helper->getArrayOfNodesForCurrentCluster(),null,5,5000,5000,10000,$cluster_helper->getCredentialsForCurrentCluster()); + + if ($is_super_cf) { + $column_family = new SuperColumnFamily($pool, $columnfamily_name); + } + else { + $column_family = new ColumnFamily($pool, $columnfamily_name); + } + + $vw_vars['results'] = ''; + + $time_start = microtime(true); + if (count($tab_keys) == 1) { + $output = $column_family->get($tab_keys[0]); + $output = array($tab_keys[0] => $output); + } + else { + $output = $column_family->multiget($tab_keys); + } + + $time_end = microtime(true); + + $cf_def = ColumnFamilyHelper::getCFInKeyspace($keyspace_name,$columnfamily_name); + + $results = ''; + foreach ($output as $key => $value) { + $vw_row_vars['key'] = $key; + $vw_row_vars['value'] = $value; + + $vw_row_vars['is_super_cf'] = $cf_def->column_type == 'Super'; + + $vw_row_vars['keyspace_name'] = $keyspace_name; + $vw_row_vars['columnfamily_name'] = $columnfamily_name; + $vw_row_vars['show_actions_link'] = true; + + $vw_row_vars['is_counter_column'] = false; + $results .= getHTML('columnfamily_browse_data_row.php',$vw_row_vars); + } + + $vw_vars['results'] = $results; + + $vw_vars['success_message'] = displaySuccessMessage('get_key',array('keys' => implode(',',$tab_keys), 'query_time' => getQueryTime($time_start,$time_end))); + } + catch (cassandra\NotFoundException $e) { + $vw_vars['success_message'] = displayInfoMessage('get_key_doesnt_exists',array('key' => $tab_keys[0])); + } + catch (Exception $e) { + $vw_vars['error_message'] = displayErrorMessage('get_key',array('message' => $e->getMessage())); + } + } + + /* + Submit query secondary index + */ + + if (isset($_POST['btn_query_secondary_index'])) { + $nb_rows = 10; + if (isset($_POST['nb_rows'])) $nb_rows = $_POST['nb_rows']; + + $keyspace_name = ''; + if (isset($_GET['keyspace_name'])) { + $keyspace_name = $_GET['keyspace_name']; + } + + $columnfamily_name = ''; + if (isset($_GET['columnfamily_name'])) { + $columnfamily_name = $_GET['columnfamily_name']; + } + + try { + $pool = new ConnectionPool($keyspace_name, $cluster_helper->getArrayOfNodesForCurrentCluster(),null,5,5000,5000,10000,$cluster_helper->getCredentialsForCurrentCluster()); + + $cf_def = ColumnFamilyHelper::getCFInKeyspace($keyspace_name,$columnfamily_name); + $is_super_cf = $cf_def->column_type == 'Super'; + + if ($is_super_cf) { + $column_family = new SuperColumnFamily($pool, $columnfamily_name); + } + else { + $column_family = new ColumnFamily($pool, $columnfamily_name); + } + + $no_index_expression = 0; + $arr_index_expression = array(); + + while (isset($_POST['index_name_'.$no_index_expression]) && isset($_POST['operator_'.$no_index_expression]) && isset($_POST['column_value_'.$no_index_expression])) { + $index_name = $_POST['index_name_'.$no_index_expression]; + $operator = $_POST['operator_'.$no_index_expression]; + $column_value = $_POST['column_value_'.$no_index_expression]; + + switch ($operator) { + case 'eq': + $operator = cassandra_IndexOperator::EQ; + break; + + case 'gte': + $operator = cassandra_IndexOperator::GTE; + break; + + case 'gt': + $operator = cassandra_IndexOperator::GT; + break; + + case 'lte': + $operator = cassandra_IndexOperator::LTE; + break; + + case 'lt': + $operator = cassandra_IndexOperator::LT; + break; + + default: + // Invalid operator + break; + } + + $arr_index_expression[] = CassandraUtil::create_index_expression($index_name, $column_value, $operator); + + $no_index_expression++; + } + + $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'; + + $vw_vars['results_secondary_index'] = ''; + $vw_vars['results'] = ''; + + $nb_results = 0; + + foreach ($result as $key => $value) { + $vw_row_vars['key'] = $key; + $vw_row_vars['value'] = $value; + + $vw_row_vars['keyspace_name'] = $keyspace_name; + $vw_row_vars['columnfamily_name'] = $columnfamily_name; + + $vw_row_vars['show_actions_link'] = false; + + $vw_vars['results_secondary_index'] .= getHTML('columnfamily_browse_data_row.php',$vw_row_vars); + + $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())); + } + } + + /* + Get a key + */ + + if ($action == 'get_key') { + $is_valid_action = true; + + $keyspace_name = ''; + if (isset($_GET['keyspace_name'])) { + $keyspace_name = $_GET['keyspace_name']; + } + + $columnfamily_name = ''; + if (isset($_GET['columnfamily_name'])) { + $columnfamily_name = $_GET['columnfamily_name']; + } + + $vw_vars['cluster_name'] = $sys_manager->describe_cluster_name(); + $vw_vars['keyspace_name'] = $keyspace_name; + $vw_vars['columnfamily_name'] = $columnfamily_name; + + $vw_vars['mode'] = 'create'; + + $cf = ColumnFamilyHelper::getCFInKeyspace($keyspace_name,$columnfamily_name); + + if (!isset($vw_vars['results'])) $vw_vars['results'] = ''; + if (!isset($vw_vars['success_message'])) $vw_vars['success_message'] = ''; + if (!isset($vw_vars['error_message'])) $vw_vars['error_message'] = ''; + + if (!isset($vw_vars['results_secondary_index'])) $vw_vars['results_secondary_index'] = ''; + if (!isset($vw_vars['success_message_secondary_index'])) $vw_vars['success_message_secondary_index'] = ''; + if (!isset($vw_vars['error_message_secondary_index'])) $vw_vars['error_message_secondary_index'] = ''; + + $index_name = array(); + foreach ($cf->column_metadata as $one_si) { + if ($one_si instanceof cassandra_ColumnDef) { + $index_name[] = $one_si->name; + } + } + + $vw_vars['index_name'] = $index_name; + + $current_page_title = 'Cassandra Cluster Admin > '.$keyspace_name.' > '.$columnfamily_name.' > Get Key'; + + $included_header = true; + echo getHTML('header.php'); + echo getHTML('columnfamily_getkey.php',$vw_vars); + } + + + /* + Submit form insert/edit a row + */ + + if (isset($_POST['btn_insert_row'])) { + $keyspace_name = ''; + if (isset($_GET['keyspace_name'])) { + $keyspace_name = $_GET['keyspace_name']; + } + + $columnfamily_name = ''; + if (isset($_GET['columnfamily_name'])) { + $columnfamily_name = $_GET['columnfamily_name']; + } + + $key = $_POST['key']; + + $pool = new ConnectionPool($keyspace_name, $cluster_helper->getArrayOfNodesForCurrentCluster(),null,5,5000,5000,10000,$cluster_helper->getCredentialsForCurrentCluster()); + $cf_def = ColumnFamilyHelper::getCFInKeyspace($keyspace_name,$columnfamily_name); + $is_super_cf = $cf_def->column_type == 'Super'; + + if ($is_super_cf) { + $column_family = new SuperColumnFamily($pool, $columnfamily_name); + } + else { + $column_family = new ColumnFamily($pool, $columnfamily_name); + } + + $no_column = 1; + + $data = array(); + + $no_scf = 1; + + while (isset($_POST['column_key_'.$no_scf]) || $no_scf == 1) { + $column_key_name = ''; + if (isset($_POST['column_key_'.$no_scf])) $column_key_name = $_POST['column_key_'.$no_scf]; + + $no_column = 1; + + while (isset($_POST['column_name_'.$no_scf.'_'.$no_column]) && isset($_POST['column_value_'.$no_scf.'_'.$no_column])) { + $column_name = $_POST['column_name_'.$no_scf.'_'.$no_column]; + $column_value = $_POST['column_value_'.$no_scf.'_'.$no_column]; + + if ($_POST['column_name_'.$no_scf.'_'.$no_column] != '' && $_POST['column_value_'.$no_scf.'_'.$no_column] != '') { + // CF + if ($column_key_name == '') { + $data[$column_name] = $column_value; + } + // SCF + else { + $data[$column_key_name][$column_name] = $column_value; + } + } + + $no_column++; + } + + $no_scf++; + } + + try { + if (!empty($key)) { + if (count($data) > 0) { + + if (isset($_POST['mode']) && $_POST['mode'] == 'edit') { + $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',array('query_time' => getQueryTime($time_start,$time_end))); + } + // Edit successful + else { + $vw_vars['success_message'] = displaySuccessMessage('edit_row',array('key' => $key,'query_time' => getQueryTime($time_start,$time_end))); + } + } + // Some fields are not filled + else { + $vw_vars['error_message'] = displayErrorMessage('insert_row_incomplete_fields'); + } + } + // A key must be specified + else { + $vw_vars['info_message'] = displayInfoMessage('insert_row_not_empty'); + } + } + catch (Exception $e) { + $vw_vars['error_message'] = displayErrormessage('insert_row',array('message' => $e->getMessage())); + } + } + + /* + Insert a row + */ + + if ($action == 'insert_row') { + $is_valid_action = true; + + $keyspace_name = ''; + if (isset($_GET['keyspace_name'])) { + $keyspace_name = $_GET['keyspace_name']; + } + + $columnfamily_name = ''; + if (isset($_GET['columnfamily_name'])) { + $columnfamily_name = $_GET['columnfamily_name']; + } + + $vw_vars['cluster_name'] = $sys_manager->describe_cluster_name(); + $vw_vars['keyspace_name'] = $keyspace_name; + $vw_vars['columnfamily_name'] = $columnfamily_name; + + if (!isset($vw_vars['success_message'])) $vw_vars['success_message'] = ''; + if (!isset($vw_vars['info_message'])) $vw_vars['info_message'] = ''; + if (!isset($vw_vars['error_message'])) $vw_vars['error_message'] = ''; + + $cf_def = ColumnFamilyHelper::getCFInKeyspace($keyspace_name,$columnfamily_name); + $vw_vars['is_super_cf'] = $cf_def->column_type == 'Super'; + + $vw_vars['key'] = ''; + $vw_vars['mode'] = 'insert'; + $vw_vars['super_key'] = ''; + + $current_page_title = 'Cassandra Cluster Admin > '.$keyspace_name.' > '.$columnfamily_name.' > Insert a Row'; + + $included_header = true; + echo getHTML('header.php'); + echo getHTML('columnfamily_insert_edit_row.php',$vw_vars); + } + + /* + Truncate column family + */ + + if ($action == 'truncate') { + $is_valid_action = true; + + $keyspace_name = ''; + if (isset($_GET['keyspace_name'])) { + $keyspace_name = $_GET['keyspace_name']; + } + + $columnfamily_name = ''; + if (isset($_GET['columnfamily_name'])) { + $columnfamily_name = $_GET['columnfamily_name']; + } + + try { + $sys_manager->truncate_column_family($keyspace_name, $columnfamily_name); + + redirect('describe_columnfamily.php?keyspace_name='.$keyspace_name.'&columnfamily_name='.$columnfamily_name); + } + catch(Exception $e) { + echo displayErrorMessage('something_wrong_happened',array('message' => $e->getMessage())); + } + } + + /* + Browse data - Using get_range() + */ + + if ($action == 'browse_data') { + $is_valid_action = true; + + $keyspace_name = ''; + if (isset($_GET['keyspace_name'])) { + $keyspace_name = $_GET['keyspace_name']; + } + + $columnfamily_name = ''; + if (isset($_GET['columnfamily_name'])) { + $columnfamily_name = $_GET['columnfamily_name']; + } + + $vw_vars['cluster_name'] = $sys_manager->describe_cluster_name(); + $vw_vars['keyspace_name'] = $keyspace_name; + $vw_vars['columnfamily_name'] = $columnfamily_name; + + try { + $describe_keyspace = $sys_manager->describe_keyspace($keyspace_name); + + $cf_def = null; + foreach ($describe_keyspace->cf_defs as $cfdef) { + if ($cfdef->name == $columnfamily_name) { + $cf_def = $cfdef; + break; + } + } + + $is_super_cf = $cf_def->column_type == 'Super'; + + $vw_row_vars['is_super_cf'] = $is_super_cf; + $vw_row_vars['is_counter_column'] = $cf_def->default_validation_class == 'org.apache.cassandra.db.marshal.CounterColumnType'; + + $pool = new ConnectionPool($keyspace_name, $cluster_helper->getArrayOfNodesForCurrentCluster(),null,5,5000,5000,10000,$cluster_helper->getCredentialsForCurrentCluster()); + + if ($is_super_cf) { + $column_family = new SuperColumnFamily($pool, $columnfamily_name); + } + else { + $column_family = new ColumnFamily($pool, $columnfamily_name); + } + + // Increment counter + if (isset($_GET['increment'])) { + $row_key = $_GET['row_key']; + $column = $_GET['column']; + + $super_column = null; + if (isset($_GET['super_column'])) $super_column = $_GET['super_column']; + + $column_family->add($row_key, $column, 1,$super_column); + } + + // Decrement counter + if (isset($_GET['decrement'])) { + $row_key = $_GET['row_key']; + $column = $_GET['column']; + + $super_column = null; + if (isset($_GET['super_column'])) $super_column = $_GET['super_column']; + + $column_family->add($row_key, $column, -1,$super_column); + } + + $offset_key = ''; + + if (isset($_GET['pos']) && $_GET['pos'] == 'prev' && isset($_SESSION['browse_data_offset_key']) && is_array($_SESSION['browse_data_offset_key'])) { + if (count($_SESSION['browse_data_offset_key']) > 1) { + array_pop($_SESSION['browse_data_offset_key']); + } + + $offset_key = array_pop($_SESSION['browse_data_offset_key']); + } + elseif (isset($_GET['offset_key'])) { + $offset_key = $_GET['offset_key']; + } + + $vw_vars['current_offset_key'] = $offset_key; + + if (empty($offset_key)) { + $_SESSION['browse_data_offset_key'] = array(); + $_SESSION['browse_data_offset_key'][] = ''; + } + else { + if (!isset($_SESSION['browse_data_offset_key']) || !is_array($_SESSION['browse_data_offset_key'])) { + $_SESSION['browse_data_offset_key'] = array(); + } + + $pos = ''; + if (isset($_GET['pos'])) $pos = $_GET['pos']; + + // Make sure it's not only a refresh of the page AND a previous click + if (end($_SESSION['browse_data_offset_key']) != $offset_key && $pos != 'prev') { + $_SESSION['browse_data_offset_key'][] = $offset_key; + + // Don't keep more then 100 previous key + if (count($_SESSION['browse_data_offset_key']) > 100) { + array_shift($_SESSION['browse_data_offset_key']); + } + } + } + + $nb_rows = 5; + if (isset($_GET['nb_rows']) && is_numeric($_GET['nb_rows']) && $_GET['nb_rows'] > 0) $nb_rows = $_GET['nb_rows']; + $vw_vars['nb_rows'] = $nb_rows; + + $included_header = true; + echo getHTML('header.php'); - $end = '
    -
+ if ($column_family->cfdef->column_type == 'Super') { + $new_value = $new_value[$super_column][$column]; + } + else { + $new_value = $new_value[$column]; + } + + redirect('counters.php?keyspace_name='.$keyspace_name.'&columnfamily_name='.$columnfamily_name.'&new_value='.$new_value); + } + catch (Exception $e) { + $_SESSION['message'] = $e->getMessage(); + redirect('counters.php?keyspace_name='.$keyspace_name.'&columnfamily_name='.$columnfamily_name.'&error=1'); + } + } - $action)); + } + } + } + + echo getHTML('footer.php'); ?> - -

JMX

- - From 249814d9b30662a8c6c38678eee1bf74bcc57277 Mon Sep 17 00:00:00 2001 From: FlashySearch Date: Thu, 27 Dec 2012 01:35:40 +0100 Subject: [PATCH 08/17] More structured interface --- views/describe_columnfamily.php | 46 +++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/views/describe_columnfamily.php b/views/describe_columnfamily.php index 66df210..f4ffdb1 100644 --- a/views/describe_columnfamily.php +++ b/views/describe_columnfamily.php @@ -10,11 +10,36 @@ -Browse Data + + + - Create Secondary Index + + +
Details
+ +
+ + + + Edit Column Family + + Truncate Column Family + + Drop Column Family + +

Column Family Details

+ + + + +Browse Data Get Key @@ -27,16 +52,9 @@ - Edit Column Family - - Truncate Column Family - - Drop Column Family + Create Secondary Index -

Column Family Details

- - 0): ?>

Secondary Indexes

@@ -47,4 +65,10 @@ 'columnfamily_name' => $columnfamily_name)); endforeach; ?> - \ No newline at end of file + + + + +
From 4aa4939554c7c7ede9b1f82038af440cc90976f0 Mon Sep 17 00:00:00 2001 From: FlashySearch Date: Thu, 27 Dec 2012 01:36:14 +0100 Subject: [PATCH 09/17] Update css/style.css --- css/style.css | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/css/style.css b/css/style.css index 76153cb..a293b6e 100644 --- a/css/style.css +++ b/css/style.css @@ -267,3 +267,12 @@ table.kcfs a { table.kcfs a:hover { text-decoration: underline; } + +#describe_columnfamily_navigation td { + width: 33%; + cursor: pointer; +} + +#keyspace_navigation td { + cursor: pointer; +} From 7929e44cf94a914f9df2c8f805ff2f0af8a83761 Mon Sep 17 00:00:00 2001 From: FlashySearch Date: Thu, 27 Dec 2012 01:36:47 +0100 Subject: [PATCH 10/17] More structured interface --- describe_keyspace.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/describe_keyspace.php b/describe_keyspace.php index b5a7808..ae2073b 100644 --- a/describe_keyspace.php +++ b/describe_keyspace.php @@ -74,10 +74,11 @@ for ($i = 0; $i < $nb_cfs; $i++) { $one_cf = $describe_keyspace->cf_defs[$i]; - $vw_vars['cf_def'] = $one_cf; + $vw_vars['cf_def'] = $one_cf; $vw_vars['columnfamily_name'] = $one_cf->name; - $vw_vars['show_edit_link'] = true; - $vw_vars['list_column_families'] .= getHTML('columnfamily_details.php',$vw_vars); + $vw_vars['show_edit_link'] = true; + $vw_vars['list_column_families'] .= '' . $vw_vars['columnfamily_name'] . ''; + // $vw_vars['list_column_families'] .= getHTML('columnfamily_details.php',$vw_vars); } } @@ -96,4 +97,4 @@ } echo getHTML('footer.php'); -?> \ No newline at end of file +?> From 11ee59c2c7d3f2992f32c4cf0e04e0792e9e3c2c Mon Sep 17 00:00:00 2001 From: FlashySearch Date: Thu, 27 Dec 2012 01:37:16 +0100 Subject: [PATCH 11/17] More structured interface --- views/describe_keyspace.php | 42 +++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/views/describe_keyspace.php b/views/describe_keyspace.php index c829409..34f05d3 100644 --- a/views/describe_keyspace.php +++ b/views/describe_keyspace.php @@ -7,16 +7,30 @@ + + + - Create New Column Family - Edit Keyspace - Drop Keyspace + + +
Details
+ +
+ + + + Edit Keyspace + Drop Keyspace + +

Keyspace Details

@@ -43,9 +57,6 @@
-

List of Column Families in Keyspace

- -

Ring

+ + + + + Create New Column Family + + +

Column Families in Keyspace

+ + +
+ + + +
From c918418629f610d76d0c95336520005627fbe307 Mon Sep 17 00:00:00 2001 From: FlashySearch Date: Thu, 27 Dec 2012 01:40:09 +0100 Subject: [PATCH 12/17] Update views/cluster_info.php --- views/cluster_info.php | 1125 ++++------------------------------------ 1 file changed, 98 insertions(+), 1027 deletions(-) diff --git a/views/cluster_info.php b/views/cluster_info.php index 1d628cf..ad1807a 100644 --- a/views/cluster_info.php +++ b/views/cluster_info.php @@ -1,1037 +1,108 @@ + + + + + + + + + + - require('include/kernel.inc.php'); - require('include/verify_login.inc.php'); - - use phpcassa\Connection\ConnectionPool; - use phpcassa\ColumnFamily; - use phpcassa\SuperColumnFamily; - use cassandra\IndexType; - - $included_header = false; - $is_valid_action = false; - $action = ''; - if (isset($_GET['action'])) $action = $_GET['action']; - - /* - Submit form edit column family - */ - - if (isset($_POST['btn_edit_columnfamily'])) { - $column_type = $_POST['column_type']; - - $comment = $_POST['comment']; - $row_cache_size = $_POST['row_cache_size']; - $row_cache_save_period_in_seconds = $_POST['row_cache_save_period_in_seconds']; - $key_cache_size = $_POST['key_cache_size']; - $key_cache_save_period_in_seconds = $_POST['key_cache_save_period_in_seconds']; - $read_repair_chance = $_POST['read_repair_chance']; - $gc_grace_seconds = $_POST['gc_grace_seconds']; - - $default_validation_class = $_POST['default_validation_class']; - $min_compaction_threshold = $_POST['min_compaction_threshold']; - $max_compaction_threshold = $_POST['max_compaction_threshold']; - - $keyspace_name = $_POST['keyspace_name']; - $columnfamily_name = $_POST['columnfamily_name']; - - $attrs = array('column_type' => $column_type, - 'comment' => $comment, - 'row_cache_size' => $row_cache_size, - 'row_cache_save_period_in_seconds' => $row_cache_save_period_in_seconds, - 'key_cache_size' => $key_cache_size, - 'key_cache_save_period_in_seconds' => $key_cache_save_period_in_seconds, - 'read_repair_chance' => $read_repair_chance, - 'gc_grace_seconds' => $gc_grace_seconds, - 'default_validation_class' => $default_validation_class, - 'min_compaction_threshold' => $min_compaction_threshold, - 'max_compaction_threshold' => $max_compaction_threshold); - - $thrift_api_version = $sys_manager->describe_version(); - - // Cassandra 0.8- - if (version_compare($thrift_api_version,THRIFT_API_VERSION_FOR_CASSANDRA_1_0,'<')) { - $attrs['memtable_operations_in_millions'] = $_POST['memtable_operations_in_millions']; - $attrs['memtable_throughput_in_mb'] = $_POST['memtable_throughput_in_mb']; - $attrs['memtable_flush_after_mins'] = $_POST['memtable_flush_after_mins']; - } - - // Cassandra 1.0+ - if (version_compare($thrift_api_version,THRIFT_API_VERSION_FOR_CASSANDRA_1_0,'>=')) { - $attrs['replicate_on_write'] = $_POST['replicate_on_write']; - $attrs['key_validation_class'] = $_POST['key_validation_class']; - $attrs['key_alias'] = $_POST['key_alias']; - $attrs['compaction_strategy'] = $_POST['compaction_strategy']; - $attrs['bloom_filter_fp_chance'] = $_POST['bloom_filter_fp_chance']; - $attrs['caching'] = $_POST['caching']; - $attrs['dclocal_read_repair_chance'] = $_POST['dclocal_read_repair_chance']; - $attrs['merge_shards_chance'] = $_POST['merge_shards_chance']; - $attrs['row_cache_provider'] = $_POST['row_cache_provider']; - $attrs['row_cache_keys_to_save'] = $_POST['row_cache_keys_to_save']; - } - - if (isset($_POST['comparator_type'])) - $attrs['comparator_type'] = $_POST['comparator_type']; - - if ($column_type == 'Super' && isset($_POST['subcomparator_type'])) { - $attrs['subcomparator_type'] = $_POST['subcomparator_type']; - } - else { - $attrs['subcomparator_type'] = null; - } - - 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,'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())); - } - } - - /* - Edit a column family - */ - - if ($action == 'edit') { - $is_valid_action = true; - - $keyspace_name = ''; - if (isset($_GET['keyspace_name'])) { - $keyspace_name = $_GET['keyspace_name']; - } - - $columnfamily_name = ''; - if (isset($_GET['columnfamily_name'])) { - $columnfamily_name = $_GET['columnfamily_name']; - } - - $vw_vars['cluster_name'] = $sys_manager->describe_cluster_name(); - $vw_vars['keyspace_name'] = $keyspace_name; - $vw_vars['columnfamily_name'] = $columnfamily_name; - - $cf = ColumnFamilyHelper::getCFInKeyspace($keyspace_name,$columnfamily_name); - - $current_page_title = 'Cassandra Cluster Admin > '.$keyspace_name.' > '.$columnfamily_name.' > Edit Column Family'; - - $included_header = true; - echo getHTML('header.php'); - - if ($cf) { - $vw_vars['column_type'] = $cf->column_type; - $vw_vars['comparator_type'] = $cf->comparator_type; - $vw_vars['subcomparator_type'] = $cf->subcomparator_type; - $vw_vars['comment'] = $cf->comment; - $vw_vars['row_cache_size'] = $cf->row_cache_size; - $vw_vars['key_cache_size'] = $cf->key_cache_size; - $vw_vars['read_repair_chance'] = $cf->read_repair_chance; - $vw_vars['gc_grace_seconds'] = $cf->gc_grace_seconds; - $vw_vars['default_validation_class'] = $cf->default_validation_class; - $vw_vars['id'] = $cf->id; - $vw_vars['min_compaction_threshold'] = $cf->min_compaction_threshold; - $vw_vars['max_compaction_threshold'] = $cf->max_compaction_threshold; - $vw_vars['row_cache_save_period_in_seconds'] = $cf->row_cache_save_period_in_seconds; - $vw_vars['key_cache_save_period_in_seconds'] = $cf->key_cache_save_period_in_seconds; - - $thrift_api_version = $sys_manager->describe_version(); - - // Cassandra 0.8- - if (version_compare($thrift_api_version,THRIFT_API_VERSION_FOR_CASSANDRA_1_0,'<')) { - $vw_vars['memtable_flush_after_mins'] = $cf->memtable_flush_after_mins; - $vw_vars['memtable_throughput_in_mb'] = $cf->memtable_throughput_in_mb; - $vw_vars['memtable_operations_in_millions'] = $cf->memtable_operations_in_millions; - } - - // Cassandra 1.0+ - if (version_compare($thrift_api_version,THRIFT_API_VERSION_FOR_CASSANDRA_1_0,'>=')) { - $vw_vars['replicate_on_write'] = $cf->replicate_on_write; - $vw_vars['key_validation_class'] = $cf->key_validation_class; - $vw_vars['key_alias'] = $cf->key_alias; - $vw_vars['compaction_strategy'] = $cf->compaction_strategy; - $vw_vars['bloom_filter_fp_chance'] = $cf->bloom_filter_fp_chance; - $vw_vars['caching'] = $cf->caching; - $vw_vars['dclocal_read_repair_chance'] = $cf->dclocal_read_repair_chance; - $vw_vars['merge_shards_chance'] = $cf->merge_shards_chance; - $vw_vars['row_cache_provider'] = $cf->row_cache_provider; - $vw_vars['row_cache_keys_to_save'] = $cf->row_cache_keys_to_save; - } - - if (!isset($vw_vars['success_message'])) $vw_vars['success_message'] = ''; - if (!isset($vw_vars['error_message'])) $vw_vars['error_message'] = ''; +
- $vw_vars['mode'] = 'edit'; - $vw_vars['thrift_api_version'] = $thrift_api_version; - - echo getHTML('create_edit_columnfamily.php',$vw_vars); - } - else { - echo displayErrorMessage('columnfamily_doesnt_exists', array('column_name' => $columnfamily_name)); - } - } - - /* - Drop a column family - */ - - if ($action == 'drop') { - $is_valid_action = true; - - $keyspace_name = ''; - if (isset($_GET['keyspace_name'])) { - $keyspace_name = $_GET['keyspace_name']; - } - - $columnfamily_name = ''; - if (isset($_GET['columnfamily_name'])) { - $columnfamily_name = $_GET['columnfamily_name']; - } - - $current_page_title = 'Cassandra Cluster Admin > '.$keyspace_name.' > '.$columnfamily_name.' > Drop Column Family'; - - try { - $sys_manager->drop_column_family($keyspace_name, $columnfamily_name); - redirect('describe_keyspace.php?keyspace_name='.$keyspace_name.'&deleted_cf=1'); - } - catch (Exception $e) { - $included_header = true; - echo getHTML('header.php'); - echo displayErrorMessage('drop_columnfamily',array('message' => $e->getMessage())); - } - } - - /* - Submit form create a secondary index - */ - - if (isset($_POST['btn_create_secondary_index'])) { - $keyspace_name = ''; - if (isset($_GET['keyspace_name'])) { - $keyspace_name = $_GET['keyspace_name']; - } - - $columnfamily_name = ''; - if (isset($_GET['columnfamily_name'])) { - $columnfamily_name = $_GET['columnfamily_name']; - } +
+ Cluster Name: + +
- $column_name = $_POST['column_name']; - $data_type = $_POST['data_type']; - $index_name = $_POST['index_name']; - - try { - $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())); - } - } - - /* - Create a secondary index - */ - - if ($action == 'create_secondary_index') { - $is_valid_action = true; - - $keyspace_name = ''; - if (isset($_GET['keyspace_name'])) { - $keyspace_name = $_GET['keyspace_name']; - } - - $columnfamily_name = ''; - if (isset($_GET['columnfamily_name'])) { - $columnfamily_name = $_GET['columnfamily_name']; - } - - $vw_vars['cluster_name'] = $sys_manager->describe_cluster_name(); - $vw_vars['keyspace_name'] = $keyspace_name; - $vw_vars['columnfamily_name'] = $columnfamily_name; - - $vw_vars['mode'] = 'create'; - - $cf = ColumnFamilyHelper::getCFInKeyspace($keyspace_name,$columnfamily_name); - - if (!isset($vw_vars['success_message'])) $vw_vars['success_message'] = ''; - if (!isset($vw_vars['error_message'])) $vw_vars['error_message'] = ''; - - $included_header = true; - $current_page_title = 'Cassandra Cluster Admin > '.$keyspace_name.' > '.$columnfamily_name.' > Create Secondary Index'; - - echo getHTML('header.php'); - echo getHTML('create_edit_secondary_index.php',$vw_vars); - } - - - /* - Submit form get key - */ - if (isset($_POST['btn_get_key'])) { - $i = 0; - $tab_keys = array(); - while (isset($_POST['key_'.$i])) { - $tab_keys[] = $_POST['key_'.$i]; - $i++; - } - - $keyspace_name = ''; - if (isset($_GET['keyspace_name'])) { - $keyspace_name = $_GET['keyspace_name']; - } - - $columnfamily_name = ''; - if (isset($_GET['columnfamily_name'])) { - $columnfamily_name = $_GET['columnfamily_name']; - } - - $cf_def = ColumnFamilyHelper::getCFInKeyspace($keyspace_name,$columnfamily_name); - $is_super_cf = $cf_def->column_type == 'Super'; - - try { - $pool = new ConnectionPool($keyspace_name, $cluster_helper->getArrayOfNodesForCurrentCluster(),null,5,5000,5000,10000,$cluster_helper->getCredentialsForCurrentCluster()); - - if ($is_super_cf) { - $column_family = new SuperColumnFamily($pool, $columnfamily_name); - } - else { - $column_family = new ColumnFamily($pool, $columnfamily_name); - } - - $vw_vars['results'] = ''; - - $time_start = microtime(true); - if (count($tab_keys) == 1) { - $output = $column_family->get($tab_keys[0]); - $output = array($tab_keys[0] => $output); - } - else { - $output = $column_family->multiget($tab_keys); - } - - $time_end = microtime(true); - - $cf_def = ColumnFamilyHelper::getCFInKeyspace($keyspace_name,$columnfamily_name); - - $results = ''; - foreach ($output as $key => $value) { - $vw_row_vars['key'] = $key; - $vw_row_vars['value'] = $value; - - $vw_row_vars['is_super_cf'] = $cf_def->column_type == 'Super'; - - $vw_row_vars['keyspace_name'] = $keyspace_name; - $vw_row_vars['columnfamily_name'] = $columnfamily_name; - $vw_row_vars['show_actions_link'] = true; - - $vw_row_vars['is_counter_column'] = false; - $results .= getHTML('columnfamily_browse_data_row.php',$vw_row_vars); - } - - $vw_vars['results'] = $results; - - $vw_vars['success_message'] = displaySuccessMessage('get_key',array('keys' => implode(',',$tab_keys), 'query_time' => getQueryTime($time_start,$time_end))); - } - catch (cassandra\NotFoundException $e) { - $vw_vars['success_message'] = displayInfoMessage('get_key_doesnt_exists',array('key' => $tab_keys[0])); - } - catch (Exception $e) { - $vw_vars['error_message'] = displayErrorMessage('get_key',array('message' => $e->getMessage())); - } - } - - /* - Submit query secondary index - */ - - if (isset($_POST['btn_query_secondary_index'])) { - $nb_rows = 10; - if (isset($_POST['nb_rows'])) $nb_rows = $_POST['nb_rows']; - - $keyspace_name = ''; - if (isset($_GET['keyspace_name'])) { - $keyspace_name = $_GET['keyspace_name']; - } - - $columnfamily_name = ''; - if (isset($_GET['columnfamily_name'])) { - $columnfamily_name = $_GET['columnfamily_name']; - } - - try { - $pool = new ConnectionPool($keyspace_name, $cluster_helper->getArrayOfNodesForCurrentCluster(),null,5,5000,5000,10000,$cluster_helper->getCredentialsForCurrentCluster()); - - $cf_def = ColumnFamilyHelper::getCFInKeyspace($keyspace_name,$columnfamily_name); - $is_super_cf = $cf_def->column_type == 'Super'; - - if ($is_super_cf) { - $column_family = new SuperColumnFamily($pool, $columnfamily_name); - } - else { - $column_family = new ColumnFamily($pool, $columnfamily_name); - } - - $no_index_expression = 0; - $arr_index_expression = array(); - - while (isset($_POST['index_name_'.$no_index_expression]) && isset($_POST['operator_'.$no_index_expression]) && isset($_POST['column_value_'.$no_index_expression])) { - $index_name = $_POST['index_name_'.$no_index_expression]; - $operator = $_POST['operator_'.$no_index_expression]; - $column_value = $_POST['column_value_'.$no_index_expression]; - - switch ($operator) { - case 'eq': - $operator = cassandra_IndexOperator::EQ; - break; - - case 'gte': - $operator = cassandra_IndexOperator::GTE; - break; - - case 'gt': - $operator = cassandra_IndexOperator::GT; - break; - - case 'lte': - $operator = cassandra_IndexOperator::LTE; - break; - - case 'lt': - $operator = cassandra_IndexOperator::LT; - break; - - default: - // Invalid operator - break; - } - - $arr_index_expression[] = CassandraUtil::create_index_expression($index_name, $column_value, $operator); - - $no_index_expression++; - } - - $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'; - - $vw_vars['results_secondary_index'] = ''; - $vw_vars['results'] = ''; - - $nb_results = 0; - - foreach ($result as $key => $value) { - $vw_row_vars['key'] = $key; - $vw_row_vars['value'] = $value; - - $vw_row_vars['keyspace_name'] = $keyspace_name; - $vw_row_vars['columnfamily_name'] = $columnfamily_name; - - $vw_row_vars['show_actions_link'] = false; - - $vw_vars['results_secondary_index'] .= getHTML('columnfamily_browse_data_row.php',$vw_row_vars); - - $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())); - } - } - - /* - Get a key - */ - - if ($action == 'get_key') { - $is_valid_action = true; - - $keyspace_name = ''; - if (isset($_GET['keyspace_name'])) { - $keyspace_name = $_GET['keyspace_name']; - } - - $columnfamily_name = ''; - if (isset($_GET['columnfamily_name'])) { - $columnfamily_name = $_GET['columnfamily_name']; - } - - $vw_vars['cluster_name'] = $sys_manager->describe_cluster_name(); - $vw_vars['keyspace_name'] = $keyspace_name; - $vw_vars['columnfamily_name'] = $columnfamily_name; - - $vw_vars['mode'] = 'create'; - - $cf = ColumnFamilyHelper::getCFInKeyspace($keyspace_name,$columnfamily_name); - - if (!isset($vw_vars['results'])) $vw_vars['results'] = ''; - if (!isset($vw_vars['success_message'])) $vw_vars['success_message'] = ''; - if (!isset($vw_vars['error_message'])) $vw_vars['error_message'] = ''; - - if (!isset($vw_vars['results_secondary_index'])) $vw_vars['results_secondary_index'] = ''; - if (!isset($vw_vars['success_message_secondary_index'])) $vw_vars['success_message_secondary_index'] = ''; - if (!isset($vw_vars['error_message_secondary_index'])) $vw_vars['error_message_secondary_index'] = ''; - - $index_name = array(); - foreach ($cf->column_metadata as $one_si) { - if ($one_si instanceof cassandra_ColumnDef) { - $index_name[] = $one_si->name; - } - } - - $vw_vars['index_name'] = $index_name; - - $current_page_title = 'Cassandra Cluster Admin > '.$keyspace_name.' > '.$columnfamily_name.' > Get Key'; - - $included_header = true; - echo getHTML('header.php'); - echo getHTML('columnfamily_getkey.php',$vw_vars); - } - - - /* - Submit form insert/edit a row - */ - - if (isset($_POST['btn_insert_row'])) { - $keyspace_name = ''; - if (isset($_GET['keyspace_name'])) { - $keyspace_name = $_GET['keyspace_name']; - } - - $columnfamily_name = ''; - if (isset($_GET['columnfamily_name'])) { - $columnfamily_name = $_GET['columnfamily_name']; - } - - $key = $_POST['key']; - - $pool = new ConnectionPool($keyspace_name, $cluster_helper->getArrayOfNodesForCurrentCluster(),null,5,5000,5000,10000,$cluster_helper->getCredentialsForCurrentCluster()); - $cf_def = ColumnFamilyHelper::getCFInKeyspace($keyspace_name,$columnfamily_name); - $is_super_cf = $cf_def->column_type == 'Super'; - - if ($is_super_cf) { - $column_family = new SuperColumnFamily($pool, $columnfamily_name); - } - else { - $column_family = new ColumnFamily($pool, $columnfamily_name); - } - - $no_column = 1; - - $data = array(); - - $no_scf = 1; - - while (isset($_POST['column_key_'.$no_scf]) || $no_scf == 1) { - $column_key_name = ''; - if (isset($_POST['column_key_'.$no_scf])) $column_key_name = $_POST['column_key_'.$no_scf]; - - $no_column = 1; - - while (isset($_POST['column_name_'.$no_scf.'_'.$no_column]) && isset($_POST['column_value_'.$no_scf.'_'.$no_column])) { - $column_name = $_POST['column_name_'.$no_scf.'_'.$no_column]; - $column_value = $_POST['column_value_'.$no_scf.'_'.$no_column]; - - if ($_POST['column_name_'.$no_scf.'_'.$no_column] != '' && $_POST['column_value_'.$no_scf.'_'.$no_column] != '') { - // CF - if ($column_key_name == '') { - $data[$column_name] = $column_value; - } - // SCF - else { - $data[$column_key_name][$column_name] = $column_value; - } - } - - $no_column++; - } - - $no_scf++; - } - - try { - if (!empty($key)) { - if (count($data) > 0) { - - if (isset($_POST['mode']) && $_POST['mode'] == 'edit') { - $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',array('query_time' => getQueryTime($time_start,$time_end))); - } - // Edit successful - else { - $vw_vars['success_message'] = displaySuccessMessage('edit_row',array('key' => $key,'query_time' => getQueryTime($time_start,$time_end))); - } - } - // Some fields are not filled - else { - $vw_vars['error_message'] = displayErrorMessage('insert_row_incomplete_fields'); - } - } - // A key must be specified - else { - $vw_vars['info_message'] = displayInfoMessage('insert_row_not_empty'); - } - } - catch (Exception $e) { - $vw_vars['error_message'] = displayErrormessage('insert_row',array('message' => $e->getMessage())); - } - } - - /* - Insert a row - */ - - if ($action == 'insert_row') { - $is_valid_action = true; - - $keyspace_name = ''; - if (isset($_GET['keyspace_name'])) { - $keyspace_name = $_GET['keyspace_name']; - } - - $columnfamily_name = ''; - if (isset($_GET['columnfamily_name'])) { - $columnfamily_name = $_GET['columnfamily_name']; - } - - $vw_vars['cluster_name'] = $sys_manager->describe_cluster_name(); - $vw_vars['keyspace_name'] = $keyspace_name; - $vw_vars['columnfamily_name'] = $columnfamily_name; - - if (!isset($vw_vars['success_message'])) $vw_vars['success_message'] = ''; - if (!isset($vw_vars['info_message'])) $vw_vars['info_message'] = ''; - if (!isset($vw_vars['error_message'])) $vw_vars['error_message'] = ''; - - $cf_def = ColumnFamilyHelper::getCFInKeyspace($keyspace_name,$columnfamily_name); - $vw_vars['is_super_cf'] = $cf_def->column_type == 'Super'; - - $vw_vars['key'] = ''; - $vw_vars['mode'] = 'insert'; - $vw_vars['super_key'] = ''; - - $current_page_title = 'Cassandra Cluster Admin > '.$keyspace_name.' > '.$columnfamily_name.' > Insert a Row'; - - $included_header = true; - echo getHTML('header.php'); - echo getHTML('columnfamily_insert_edit_row.php',$vw_vars); - } - - /* - Truncate column family - */ - - if ($action == 'truncate') { - $is_valid_action = true; - - $keyspace_name = ''; - if (isset($_GET['keyspace_name'])) { - $keyspace_name = $_GET['keyspace_name']; - } - - $columnfamily_name = ''; - if (isset($_GET['columnfamily_name'])) { - $columnfamily_name = $_GET['columnfamily_name']; - } - - try { - $sys_manager->truncate_column_family($keyspace_name, $columnfamily_name); - - redirect('describe_columnfamily.php?keyspace_name='.$keyspace_name.'&columnfamily_name='.$columnfamily_name); - } - catch(Exception $e) { - echo displayErrorMessage('something_wrong_happened',array('message' => $e->getMessage())); - } - } - - /* - Browse data - Using get_range() - */ - - if ($action == 'browse_data') { - $is_valid_action = true; - - $keyspace_name = ''; - if (isset($_GET['keyspace_name'])) { - $keyspace_name = $_GET['keyspace_name']; - } - - $columnfamily_name = ''; - if (isset($_GET['columnfamily_name'])) { - $columnfamily_name = $_GET['columnfamily_name']; - } - - $vw_vars['cluster_name'] = $sys_manager->describe_cluster_name(); - $vw_vars['keyspace_name'] = $keyspace_name; - $vw_vars['columnfamily_name'] = $columnfamily_name; - - try { - $describe_keyspace = $sys_manager->describe_keyspace($keyspace_name); - - $cf_def = null; - foreach ($describe_keyspace->cf_defs as $cfdef) { - if ($cfdef->name == $columnfamily_name) { - $cf_def = $cfdef; - break; - } - } - - $is_super_cf = $cf_def->column_type == 'Super'; - - $vw_row_vars['is_super_cf'] = $is_super_cf; - $vw_row_vars['is_counter_column'] = $cf_def->default_validation_class == 'org.apache.cassandra.db.marshal.CounterColumnType'; - - $pool = new ConnectionPool($keyspace_name, $cluster_helper->getArrayOfNodesForCurrentCluster(),null,5,5000,5000,10000,$cluster_helper->getCredentialsForCurrentCluster()); - - if ($is_super_cf) { - $column_family = new SuperColumnFamily($pool, $columnfamily_name); - } - else { - $column_family = new ColumnFamily($pool, $columnfamily_name); - } - - // Increment counter - if (isset($_GET['increment'])) { - $row_key = $_GET['row_key']; - $column = $_GET['column']; - - $super_column = null; - if (isset($_GET['super_column'])) $super_column = $_GET['super_column']; - - $column_family->add($row_key, $column, 1,$super_column); - } - - // Decrement counter - if (isset($_GET['decrement'])) { - $row_key = $_GET['row_key']; - $column = $_GET['column']; - - $super_column = null; - if (isset($_GET['super_column'])) $super_column = $_GET['super_column']; - - $column_family->add($row_key, $column, -1,$super_column); - } - - $offset_key = ''; - - if (isset($_GET['pos']) && $_GET['pos'] == 'prev' && isset($_SESSION['browse_data_offset_key']) && is_array($_SESSION['browse_data_offset_key'])) { - if (count($_SESSION['browse_data_offset_key']) > 1) { - array_pop($_SESSION['browse_data_offset_key']); - } - - $offset_key = array_pop($_SESSION['browse_data_offset_key']); - } - elseif (isset($_GET['offset_key'])) { - $offset_key = $_GET['offset_key']; - } - - $vw_vars['current_offset_key'] = $offset_key; - - if (empty($offset_key)) { - $_SESSION['browse_data_offset_key'] = array(); - $_SESSION['browse_data_offset_key'][] = ''; - } - else { - if (!isset($_SESSION['browse_data_offset_key']) || !is_array($_SESSION['browse_data_offset_key'])) { - $_SESSION['browse_data_offset_key'] = array(); - } - - $pos = ''; - if (isset($_GET['pos'])) $pos = $_GET['pos']; - - // Make sure it's not only a refresh of the page AND a previous click - if (end($_SESSION['browse_data_offset_key']) != $offset_key && $pos != 'prev') { - $_SESSION['browse_data_offset_key'][] = $offset_key; - - // Don't keep more then 100 previous key - if (count($_SESSION['browse_data_offset_key']) > 100) { - array_shift($_SESSION['browse_data_offset_key']); - } - } - } - - $nb_rows = 5; - if (isset($_GET['nb_rows']) && is_numeric($_GET['nb_rows']) && $_GET['nb_rows'] > 0) $nb_rows = $_GET['nb_rows']; - $vw_vars['nb_rows'] = $nb_rows; - - $included_header = true; - echo getHTML('header.php'); + Cluster Partitioner:
+ Cluster Snitch:
+ Thrift API Version:

+ Schema Versions:
+ + $servers): + foreach ($servers as $server): + echo ''; + if ($version == 'UNREACHABLE'): + echo ''; + else: + echo ''; + endif; + echo ''; + endforeach; + endforeach; + ?> +
×'.$server.''.$version.''.$server.''.$version.'
+
- $output = $column_family->get_range($offset_key,'',$nb_rows,null); - - $vw_vars['results'] = ''; - $nb_results = 0; - - foreach ($output as $key => $value) { - $vw_row_vars['key'] = $key; - $vw_row_vars['value'] = $value; - - $vw_row_vars['keyspace_name'] = $keyspace_name; - $vw_row_vars['columnfamily_name'] = $columnfamily_name; - - $vw_row_vars['show_actions_link'] = true; - - $vw_vars['results'] .= getHTML('columnfamily_browse_data_row.php',$vw_row_vars); - - $nb_results++; - } - - $vw_vars['show_begin_page_link'] = $offset_key != ''; - $vw_vars['show_prev_page_link'] = $offset_key != '' && count($_SESSION['browse_data_offset_key']) > 0; - - // We got the number of rows we asked for, display "Next Page" link - if ($nb_results == $nb_rows) { - $offset_key = ++$key; - - $vw_vars['offset_key'] = $offset_key; - $vw_vars['show_next_page_link'] = true; - } - else { - $vw_vars['offset_key'] = ''; - $vw_vars['show_next_page_link'] = false; - } - - $current_page_title = 'Cassandra Cluster Admin > '.$keyspace_name.' > '.$columnfamily_name.' > Browse Data'; - - $vw_vars['is_counter_column'] = $vw_row_vars['is_counter_column']; - - echo getHTML('columnfamily_browse_data.php',$vw_vars); - } - catch (cassandra\NotFoundException $e) { - echo displayErrorMessage('columnfamily_doesnt_exists',array('column_name' => $columnfamily_name)); - } - catch (Exception $e) { - echo displayErrorMessage('something_wrong_happened',array('message' => $e->getMessage())); - } - } - - /* - Edit a row - */ - if ($action == 'edit_row') { - $is_valid_action = true; - - $keyspace_name = ''; - if (isset($_GET['keyspace_name'])) { - $keyspace_name = $_GET['keyspace_name']; - } - - $columnfamily_name = ''; - if (isset($_GET['columnfamily_name'])) { - $columnfamily_name = $_GET['columnfamily_name']; - } - - $key = ''; - if (isset($_GET['key'])) { - $key = $_GET['key']; - } - - $super_key = ''; - if (isset($_GET['super_key'])) { - $super_key = $_GET['super_key']; - } - - $vw_vars['cluster_name'] = $sys_manager->describe_cluster_name(); - $vw_vars['keyspace_name'] = $keyspace_name; - $vw_vars['columnfamily_name'] = $columnfamily_name; - - if (!isset($vw_vars['success_message'])) $vw_vars['success_message'] = ''; - if (!isset($vw_vars['info_message'])) $vw_vars['info_message'] = ''; - if (!isset($vw_vars['error_message'])) $vw_vars['error_message'] = ''; - - $cf_def = ColumnFamilyHelper::getCFInKeyspace($keyspace_name,$columnfamily_name); - - $is_super_cf = $cf_def->column_type == 'Super'; - $vw_vars['is_super_cf'] = $cf_def->column_type == 'Super'; - - $vw_vars['key'] = $key; - $vw_vars['super_key'] = $super_key; - - $vw_vars['mode'] = 'edit'; - - try { - $pool = new ConnectionPool($keyspace_name, $cluster_helper->getArrayOfNodesForCurrentCluster(),null,5,5000,5000,10000,$cluster_helper->getCredentialsForCurrentCluster()); - - if ($is_super_cf) { - $column_family = new SuperColumnFamily($pool, $columnfamily_name); - } - else { - $column_family = new ColumnFamily($pool, $columnfamily_name); - } - - $vw_vars['results'] = ''; + - $output = $column_family->get($key); - $vw_vars['output'] = $output; - } - catch (Exception $e) { - echo displayErrorMessage('something_wrong_happened',array('message' => $e->getMessage())); - } - - $current_page_title = 'Cassandra Cluster Admin > '.$keyspace_name.' > '.$columnfamily_name.' > Edit Row'; - - $included_header = true; - echo getHTML('header.php'); - echo getHTML('columnfamily_insert_edit_row.php',$vw_vars); - } - - /* - Delete a row - */ - if ($action == 'delete_row') { - $is_valid_action = true; - - $keyspace_name = ''; - if (isset($_GET['keyspace_name'])) { - $keyspace_name = $_GET['keyspace_name']; - } - - $columnfamily_name = ''; - if (isset($_GET['columnfamily_name'])) { - $columnfamily_name = $_GET['columnfamily_name']; - } - - $key = ''; - if (isset($_GET['key'])) { - $key = $_GET['key']; - } - - $super_column_key = null; - if (isset($_GET['super_column_key'])) { - $super_column_key = $_GET['super_column_key']; - } - - try { - $pool = new ConnectionPool($keyspace_name, $cluster_helper->getArrayOfNodesForCurrentCluster(),null,5,5000,5000,10000,$cluster_helper->getCredentialsForCurrentCluster()); - - $cf_def = ColumnFamilyHelper::getCFInKeyspace($keyspace_name,$columnfamily_name); - $is_super_cf = $cf_def->column_type == 'Super'; - - if ($is_super_cf) { - $column_family = new SuperColumnFamily($pool, $columnfamily_name); - } - else { - $column_family = new ColumnFamily($pool, $columnfamily_name); - } - - $column_family->remove($key,null,$super_column_key); - - redirect('columnfamily_action.php?action=browse_data&keyspace_name='.$keyspace_name.'&columnfamily_name='.$columnfamily_name); - } - catch (cassandra\NotFoundException $e) { - $included_header = true; - echo getHTML('header.php'); - echo displayErrorMessage('columnfamily_doesnt_exists',array('column_name' => $columnfamily_name)); - } - catch (Exception $e) { - $included_header = true; - echo getHTML('header.php'); - echo displayErrorMessage('something_wrong_happened',array('message' => $e->getMessage())); - } - } - - /* - Modify counter - */ - if (isset($_POST['btn_modify_counter'])) { - $is_valid_action = true; - - $key = ''; - if (isset($_POST['key'])) $key = $_POST['key']; - - $super_column = null; - if (isset($_POST['super_column'])) $super_column = $_POST['super_column']; - - $column = ''; - if (isset($_POST['column'])) $column = $_POST['column']; - - $action = ''; - if (isset($_POST['action'])) $action = $_POST['action']; - - $value = ''; - if (isset($_POST['value'])) $value = $_POST['value']; +
    +

    Keyspaces and Column Families

    - $keyspace_name = ''; - if (isset($_POST['keyspace_name'])) $keyspace_name = $_POST['keyspace_name']; - - $columnfamily_name = ''; - if (isset($_POST['columnfamily_name'])) $columnfamily_name = $_POST['columnfamily_name']; - - try { - $pool = new ConnectionPool($keyspace_name, $cluster_helper->getArrayOfNodesForCurrentCluster(),null,5,5000,5000,10000,$cluster_helper->getCredentialsForCurrentCluster()); - - $cf_def = ColumnFamilyHelper::getCFInKeyspace($keyspace_name,$columnfamily_name); - $is_super_cf = $cf_def->column_type == 'Super'; - - if ($is_super_cf) { - $column_family = new SuperColumnFamily($pool, $columnfamily_name); - } - else { - $column_family = new ColumnFamily($pool, $columnfamily_name); - } - - if ($action == 'dec') { - $value *= -1; - } - - $column_family->add($key, $super_column, $column, $value); - - $new_value = $column_family->get($key); + Create New Keyspace - if ($column_family->cfdef->column_type == 'Super') { - $new_value = $new_value[$super_column][$column]; - } - else { - $new_value = $new_value[$column]; - } - - redirect('counters.php?keyspace_name='.$keyspace_name.'&columnfamily_name='.$columnfamily_name.'&new_value='.$new_value); - } - catch (Exception $e) { - $_SESSION['message'] = $e->getMessage(); - redirect('counters.php?keyspace_name='.$keyspace_name.'&columnfamily_name='.$columnfamily_name.'&error=1'); - } - } +

    + + + '; + $beg .= ''; + $end .= ''; + elseif ($i/2 == intval($i/2)): + $beg = ''; + else: + $beg = ''; + $end .= ''; + endif; + + echo $beg; + + $keyspace_name = $keyspaces_name[$i]; + + echo '
  • '.$keyspace_name.''; + echo '
      '; + $nb_cf = count($keyspaces_details[$i]['columnfamilies_name']); + for ($j = 0; $j < $nb_cf; $j++): + $columnfamily_name = $keyspaces_details[$i]['columnfamilies_name'][$j]; + echo '
    • '.$columnfamily_name.'
    • '; + endfor; + echo '
    '; + echo '
  • '; + + echo $end; + endfor; + ?> +
    '; + + $end = '
    '; - if (!$included_header) { - echo getHTML('header.php'); - - if (!$is_valid_action) { - // No action specified - if (empty($action)) { - echo displayErrorMessage('no_action_specified'); - } - // Invalid action specified - else { - echo displayErrorMessage('invalid_action_specified',array('action' => $action)); - } - } - } - - echo getHTML('footer.php'); + $end = ''; + + $end = '
    +
+ + + +

JMX

+ + From c583fdfef6833b009a68e5e8eebd7927fdd8f4f8 Mon Sep 17 00:00:00 2001 From: FlashySearch Date: Thu, 27 Dec 2012 02:31:49 +0100 Subject: [PATCH 13/17] Update describe_keyspace.php --- describe_keyspace.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/describe_keyspace.php b/describe_keyspace.php index ae2073b..50ac302 100644 --- a/describe_keyspace.php +++ b/describe_keyspace.php @@ -77,8 +77,8 @@ $vw_vars['cf_def'] = $one_cf; $vw_vars['columnfamily_name'] = $one_cf->name; $vw_vars['show_edit_link'] = true; - $vw_vars['list_column_families'] .= '' . $vw_vars['columnfamily_name'] . ''; - // $vw_vars['list_column_families'] .= getHTML('columnfamily_details.php',$vw_vars); + $vw_vars['list_column_families'] .= ''; + $vw_vars['list_column_families'] .= getHTML('columnfamily_short_details.php',$vw_vars); } } From f24cc634bebb8ff0ef2a5ca8473ffb21d105764b Mon Sep 17 00:00:00 2001 From: FlashySearch Date: Wed, 26 Dec 2012 17:35:01 -0800 Subject: [PATCH 14/17] Create columnfamily_short_details.php --- views/columnfamily_short_details.php | 1 + 1 file changed, 1 insertion(+) create mode 100644 views/columnfamily_short_details.php diff --git a/views/columnfamily_short_details.php b/views/columnfamily_short_details.php new file mode 100644 index 0000000..a24c780 --- /dev/null +++ b/views/columnfamily_short_details.php @@ -0,0 +1 @@ + From 7601b5a18c8585a15a23927f31c1397a1cbcf11e Mon Sep 17 00:00:00 2001 From: FlashySearch Date: Thu, 27 Dec 2012 02:39:55 +0100 Subject: [PATCH 15/17] Update views/describe_columnfamily.php --- views/describe_columnfamily.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/views/describe_columnfamily.php b/views/describe_columnfamily.php index f4ffdb1..8cbb48a 100644 --- a/views/describe_columnfamily.php +++ b/views/describe_columnfamily.php @@ -23,7 +23,7 @@
Edit Column Family @@ -65,10 +65,9 @@ 'columnfamily_name' => $columnfamily_name)); endforeach; ?> - -
From e4c0d4da57d9a412acd18b163688c07a511b29fd Mon Sep 17 00:00:00 2001 From: FlashySearch Date: Thu, 27 Dec 2012 02:40:13 +0100 Subject: [PATCH 16/17] Update views/describe_keyspace.php --- views/describe_keyspace.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/describe_keyspace.php b/views/describe_keyspace.php index 34f05d3..64c238e 100644 --- a/views/describe_keyspace.php +++ b/views/describe_keyspace.php @@ -23,7 +23,7 @@ From ea838de56fe8a3d2755435231ec0c43109acdc5c Mon Sep 17 00:00:00 2001 From: FlashySearch Date: Thu, 27 Dec 2012 02:49:48 +0100 Subject: [PATCH 17/17] That line.... --- describe_keyspace.php | 1 - 1 file changed, 1 deletion(-) diff --git a/describe_keyspace.php b/describe_keyspace.php index 50ac302..9fa121c 100644 --- a/describe_keyspace.php +++ b/describe_keyspace.php @@ -77,7 +77,6 @@ $vw_vars['cf_def'] = $one_cf; $vw_vars['columnfamily_name'] = $one_cf->name; $vw_vars['show_edit_link'] = true; - $vw_vars['list_column_families'] .= ''; $vw_vars['list_column_families'] .= getHTML('columnfamily_short_details.php',$vw_vars); } }