chukwa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ey...@apache.org
Subject svn commit: r775017 - /hadoop/chukwa/trunk/conf/database_upgrade_0.1.1-0.1.2.sql
Date Fri, 15 May 2009 06:04:07 GMT
Author: eyang
Date: Fri May 15 06:04:06 2009
New Revision: 775017

URL: http://svn.apache.org/viewvc?rev=775017&view=rev
Log:
CHUKWA-236. Added migration script for moving database schema for Chukwa 0.1.1 to Chukwa 0.1.2.
(Eric Yang)

Added:
    hadoop/chukwa/trunk/conf/database_upgrade_0.1.1-0.1.2.sql

Added: hadoop/chukwa/trunk/conf/database_upgrade_0.1.1-0.1.2.sql
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/conf/database_upgrade_0.1.1-0.1.2.sql?rev=775017&view=auto
==============================================================================
--- hadoop/chukwa/trunk/conf/database_upgrade_0.1.1-0.1.2.sql (added)
+++ hadoop/chukwa/trunk/conf/database_upgrade_0.1.1-0.1.2.sql Fri May 15 06:04:06 2009
@@ -0,0 +1,60 @@
+DELIMITER $$
+DROP PROCEDURE IF EXISTS UpgradeTable$$
+CREATE PROCEDURE UpgradeTable()
+BEGIN
+    DECLARE str VARCHAR(4000);
+    DECLARE tname VARCHAR(255);
+    DECLARE counter INT DEFAULT 0;
+    DECLARE st CURSOR FOR SELECT t.TABLE_NAME FROM INFORMATION_SCHEMA.TABLES t WHERE t.TABLE_NAME
LIKE 'mr_job_%' and t.TABLE_NAME!='mr_job_template';
+    DECLARE cnt CURSOR FOR SELECT count(t.TABLE_NAME) FROM INFORMATION_SCHEMA.TABLES t WHERE
t.TABLE_NAME LIKE 'mr_job_%' and t.TABLE_NAME!='mr_job_template';
+    DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET counter = counter - 1;
+    OPEN cnt;
+    FETCH cnt INTO counter;
+    CLOSE cnt;
+    OPEN st;
+    REPEAT
+        FETCH st INTO tname;
+        SET @str = CONCAT('ALTER IGNORE TABLE ',tname,' ADD COLUMN finished_maps bigint default
0, ADD COLUMN finished_reduces bigint default 0, ADD COLUMN failed_maps bigint default 0,
ADD COLUMN failed_reduces bigint default 0, ADD COLUMN total_maps bigint default 0, ADD COLUMN
total_reduces bigint default 0, ADD COLUMN reduce_shuffle_bytes bigint default 0;');
+        SELECT tname;
+        PREPARE stmt from @str;
+        EXECUTE stmt;
+        COMMIT;
+        DEALLOCATE PREPARE stmt;	
+        SET counter = counter - 1;
+	UNTIL counter=0 END REPEAT;
+    CLOSE st;
+END$$
+DELIMITER ;
+
+call UpgradeTable();
+
+DELIMITER $$
+DROP PROCEDURE IF EXISTS UpgradeTable$$
+CREATE PROCEDURE UpgradeTable()
+BEGIN
+    DECLARE str VARCHAR(4000);
+    DECLARE tname VARCHAR(255);
+    DECLARE counter INT DEFAULT 0;
+    DECLARE st CURSOR FOR SELECT t.TABLE_NAME FROM INFORMATION_SCHEMA.TABLES t WHERE t.TABLE_NAME
LIKE 'mr_task_%' and t.TABLE_NAME!='mr_task_template';
+    DECLARE cnt CURSOR FOR SELECT count(t.TABLE_NAME) FROM INFORMATION_SCHEMA.TABLES t WHERE
t.TABLE_NAME LIKE 'mr_task_%' and t.TABLE_NAME!='mr_task_template';
+    DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET counter = counter - 1;
+    OPEN cnt;
+    FETCH cnt INTO counter;
+    CLOSE cnt;
+    OPEN st;
+	REPEAT
+        FETCH st INTO tname;
+        SET @str = CONCAT('ALTER IGNORE TABLE ',tname,' ADD COLUMN type VARCHAR(20),ADD COLUMN
reduce_shuffle_bytes bigint default 0,ADD COLUMN hostname VARCHAR(80),ADD COLUMN shuffle_finished
timestamp default 0,ADD COLUMN sort_finished timestamp default 0,ADD COLUMN spilts bigint
default 0;');
+        SELECT tname;
+        PREPARE stmt from @str;
+        EXECUTE stmt;
+        COMMIT;
+        DEALLOCATE PREPARE stmt;
+        SET counter = counter - 1;
+        UNTIL counter=0 END REPEAT;
+    CLOSE st;
+END$$
+DELIMITER ;
+
+call UpgradeTable();
+DROP PROCEDURE IF EXISTS UpgradeTable;



Mime
View raw message