Mass_parse: Add resume command

pull/620/head
gnosygnu 8 years ago
parent cef2d7e2f6
commit f138db17ca

@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.addons.bldrs.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; package gplx.xowa.addons.bldrs.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*;
import gplx.xowa.bldrs.wkrs.*; import gplx.xowa.bldrs.wkrs.*;
import gplx.xowa.addons.bldrs.files.cmds.*; import gplx.xowa.addons.bldrs.files.cmds.*;
import gplx.xowa.addons.bldrs.mass_parses.inits.*; import gplx.xowa.addons.bldrs.mass_parses.parses.*; import gplx.xowa.addons.bldrs.mass_parses.makes.*; import gplx.xowa.addons.bldrs.mass_parses.inits.*; import gplx.xowa.addons.bldrs.mass_parses.parses.*; import gplx.xowa.addons.bldrs.mass_parses.makes.*; import gplx.xowa.addons.bldrs.mass_parses.resumes.*;
import gplx.xowa.addons.bldrs.files.cksums.*; import gplx.xowa.addons.bldrs.files.cksums.*;
import gplx.xowa.addons.bldrs.app_cfgs.wm_server_cfgs.*; import gplx.xowa.addons.bldrs.app_cfgs.wm_server_cfgs.*;
public class Xoax_builds_files_addon implements Xoax_addon_itm, Xoax_addon_itm__bldr { public class Xoax_builds_files_addon implements Xoax_addon_itm, Xoax_addon_itm__bldr {
@ -46,6 +46,7 @@ public class Xoax_builds_files_addon implements Xoax_addon_itm, Xoax_addon_itm__
, Xomp_init_cmd.Prototype , Xomp_init_cmd.Prototype
, Xomp_parse_cmd.Prototype , Xomp_parse_cmd.Prototype
, Xomp_make_cmd.Prototype , Xomp_make_cmd.Prototype
, Xomp_resume_cmd.Prototype
, Xocksum_calc_cmd.Prototype , Xocksum_calc_cmd.Prototype
, Xowm_server_cfg_cmd.Prototype , Xowm_server_cfg_cmd.Prototype

@ -54,7 +54,8 @@ public class Xomp_prog_mgr {
// save to file // save to file
tmp_bfr.Add_int_fixed(pages_done, 12).Add_byte_pipe(); tmp_bfr.Add_int_fixed(pages_done, 12).Add_byte_pipe();
tmp_bfr.Add_int_fixed(memory_used, 6).Add_byte_pipe(); tmp_bfr.Add_int_fixed(memory_used, 6).Add_byte_pipe();
tmp_bfr.Add_long_variable(perf_diff).Add_byte_nl(); tmp_bfr.Add_long_variable(perf_diff).Add_byte_pipe();
tmp_bfr.Add_dte(Datetime_now.Get()).Add_byte_nl();
Io_mgr.Instance.AppendFilBfr(perf_url, tmp_bfr); Io_mgr.Instance.AppendFilBfr(perf_url, tmp_bfr);
} }
} }

@ -0,0 +1,29 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.addons.bldrs.mass_parses.resumes; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.mass_parses.*;
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wkrs.*;
public class Xomp_resume_cmd extends Xob_cmd__base {
public Xomp_resume_cmd(Xob_bldr bldr, Xowe_wiki wiki) {super(bldr, wiki);}
@Override public void Cmd_run() {
new Xomp_resume_mgr().Exec(wiki);
}
@Override public String Cmd_key() {return BLDR_CMD_KEY;} private static final String BLDR_CMD_KEY = "wiki.mass_parse.resume";
public static final Xob_cmd Prototype = new Xomp_resume_cmd(null, null);
@Override public Xob_cmd Cmd_clone(Xob_bldr bldr, Xowe_wiki wiki) {return new Xomp_resume_cmd(bldr, wiki);}
}

@ -0,0 +1,47 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.addons.bldrs.mass_parses.resumes; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.mass_parses.*;
import gplx.dbs.*; import gplx.dbs.utls.*;
import gplx.xowa.addons.bldrs.mass_parses.dbs.*;
class Xomp_resume_mgr {
public void Exec(Xowe_wiki wiki) {
// init
Xomp_mgr_db mgr_db = Xomp_mgr_db.New__load(wiki);
Db_conn mgr_conn = mgr_db.Conn();
// clear out page_status
Gfo_usr_dlg_.Instance.Prog_many("", "", "xomp_resume:clearing status");
mgr_conn.Exec_sql("UPDATE xomp_page SET page_status = 0");
// update mgr.xomp_page.status for each row in wkr.html
Db_attach_mgr attach_mgr = new Db_attach_mgr(mgr_conn);
int wkrs_len = mgr_db.Tbl__wkr().Select_count();
String sql = Db_sql_.Make_by_fmt
( String_.Ary
( "UPDATE xomp_page"
, "SET page_status = 1"
, "WHERE page_id IN (SELECT page_id FROM <wkr_db>html)"
));
for (int i = 0; i < wkrs_len; ++i) {
Gfo_usr_dlg_.Instance.Prog_many("", "", "xomp_resume:updating status; wkr=~{0}", i);
Xomp_wkr_db wkr_db = Xomp_wkr_db.New(mgr_db.Dir(), i);
attach_mgr.Conn_links_(new Db_attach_itm("wkr_db", wkr_db.Conn()));
attach_mgr.Exec_sql(sql);
}
}
}
Loading…
Cancel
Save