本文描述连接器的提供与外界交互的servlet接口,连接器与外部是通过xml格式数据交互的

1)  获取所有连接类型

提交地址:http://localhost:8080/connector-manager/getConnectorList
提交方式:GET
返回数据:

<CmResponse>
<Info>Google Search Appliance Connector Manager ; Sun Microsystems Inc. Java HotSpot(TM) Client VM 1.6.0_45; Windows 2003 5.2 (x86)</Info>
<StatusId>0</StatusId>
<ConnectorTypes>
<ConnectorType>DBConnector</ConnectorType>
</ConnectorTypes>
</CmResponse>

2) 获取创建连接实例表单html

提交地址:http://localhost:8080/connector-manager/getConfigForm?ConnectorType=DBConnector&Lang=zh
提交方式:GET

参数 ConnectorType 值为连接类型;Lang为返回语言

返回数据:

<?xml version="1.0" encoding="utf-8"?>

<CmResponse>
<StatusId>0</StatusId>
<ConfigureResponse>
<FormSnippet><![CDATA[<tr style='display: none'><td>
<script type='text/javascript'>
function getVisibility(disabled) {
if (disabled) { return 'hidden'; } else { return 'visible'; }
}
function setDisabledProperties(xslt, urlField, docIdField, lobField){
document.getElementById('xslt').disabled=xslt;
document.getElementById('documentURLField').disabled=urlField;
document.getElementById('documentIdField').disabled=docIdField;
document.getElementById('baseURL').disabled=docIdField;
document.getElementById('lobField').disabled=lobField;
document.getElementById('fetchURLField').disabled=lobField;
document.getElementById('documentURLFieldStar').style.visibility=getVisibility(urlField);
document.getElementById('documentIdFieldStar').style.visibility=getVisibility(docIdField);
document.getElementById('baseURLStar').style.visibility=getVisibility(docIdField);
document.getElementById('lobFieldStar').style.visibility=getVisibility(lobField);
}
</script>
</td></tr>
<tr valign="top"><td colspan="1" rowspan="1" style="white-space:nowrap"><div style="float: left;">JDBC Driver Classname</div><div style="text-align: right; color: red; font-weight: bold; margin-right: 0.3em;">*</div></td>
<td colspan="1" rowspan="1" style="white-space:nowrap"><input type="text" size="50" name="driverClassName" id="driverClassName"/></td>
</tr>
<tr valign="top"><td colspan="1" rowspan="1" style="white-space:nowrap"><div style="float: left;">JDBC Connection URL</div><div style="text-align: right; color: red; font-weight: bold; margin-right: 0.3em;">*</div></td>
<td colspan="1" rowspan="1" style="white-space:nowrap"><input type="text" size="50" name="connectionUrl" id="connectionUrl"/></td>
</tr>
<tr valign="top"><td colspan="1" rowspan="1" style="white-space:nowrap"><div style="float: left;">用户名</div><div style="text-align: right; color: red; font-weight: bold; margin-right: 0.3em;">*</div></td>
<td colspan="1" rowspan="1" style="white-space:nowrap"><input type="text" size="50" name="login" id="login"/></td>
</tr>
<tr valign="top"><td colspan="1" rowspan="1" style="white-space:nowrap"><div style="float: left;">密码</div></td>
<td colspan="1" rowspan="1" style="white-space:nowrap"><input type="password" size="50" name="password" id="password"/></td>
</tr>
<tr valign="top"><td colspan="1" rowspan="1" style="white-space:nowrap"><div style="float: left;">SQL Query</div><div style="text-align: right; color: red; font-weight: bold; margin-right: 0.3em;">*</div></td>
<td colspan="1" rowspan="1" style="white-space:nowrap"><textarea rows="10" cols="50" name="sqlQuery" id="sqlQuery"></textarea></td>
</tr>
<tr valign="top"><td colspan="1" rowspan="1" style="white-space:nowrap"><div style="float: left;">Primary Keys (separated by comma)</div><div style="text-align: right; color: red; font-weight: bold; margin-right: 0.3em;">*</div></td>
<td colspan="1" rowspan="1" style="white-space:nowrap"><input type="text" size="50" name="primaryKeysString" id="primaryKeysString"/></td>
</tr>
<tr valign="top"><td colspan="1" rowspan="1" style="white-space:nowrap"><div style="float: left;">Last Modified Date Field</div></td>
<td colspan="1" rowspan="1" style="white-space:nowrap"><input type="text" size="50" name="lastModifiedDate" id="lastModifiedDate"/></td>
</tr>
<tr valign="top"><td colspan="1" rowspan="1" style="white-space:nowrap"><div style="float: left;">Document Content</div></td>
<td colspan="1" rowspan="1" style="white-space:nowrap"></td>
</tr>
<tr valign="top"><td colspan="1" rowspan="1" style="white-space:nowrap"><div style='text-align:right; width:40px; float:left; margin-right:5px'><input type="radio" name="extMetadataType" value="noExt" id="extMetadataType_noExt" checked="checked" onclick="javascript:setDisabledProperties(false, true, true, true)"/></div><div style="float: left;"><label for="extMetadataType_noExt">Stylesheet for serving results</label></div></td>
<td colspan="1" rowspan="1" style="white-space:nowrap"><textarea rows="10" cols="50" name="xslt" id="xslt"></textarea></td>
</tr>
<tr valign="top"><td colspan="1" rowspan="1" style="white-space:nowrap"><div style='text-align:right; width:40px; float:left; margin-right:5px'><input type="radio" name="extMetadataType" value="lob" id="extMetadataType_lob" onclick="javascript:setDisabledProperties(true, true, true, false)"/></div><div style="float: left;"><label for="extMetadataType_lob">BLOB or CLOB Field</label></div><div id="lobFieldStar" style="text-align: right; color: red; font-weight: bold; margin-right: 0.3em; float: right; visibility: hidden;">*</div></td>
<td colspan="1" rowspan="1" style="white-space:nowrap"><input type="text" size="50" name="lobField" id="lobField" disabled="disabled"/></td>
</tr>
<tr valign="top"><td align="center"><div style="margin-left:45px; float: left;">Display URL Field</div></td>
<td colspan="1" rowspan="1" style="white-space:nowrap"><input type="text" size="50" name="fetchURLField" id="fetchURLField" disabled="disabled"/></td>
</tr>
<tr valign="top"><td colspan="1" rowspan="1" style="white-space:nowrap"><div style='text-align:right; width:40px; float:left; margin-right:5px'><input type="radio" name="extMetadataType" value="url" id="extMetadataType_url" onclick="javascript:setDisabledProperties(true, false, true, true)"/></div><div style="float: left;"><label for="extMetadataType_url">Document URL Field</label></div><div id="documentURLFieldStar" style="text-align: right; color: red; font-weight: bold; margin-right: 0.3em; float: right; visibility: hidden;">*</div></td>
<td colspan="1" rowspan="1" style="white-space:nowrap"><input type="text" size="50" name="documentURLField" id="documentURLField" disabled="disabled"/></td>
</tr>
<tr valign="top"><td colspan="1" rowspan="1" style="white-space:nowrap"><div style='text-align:right; width:40px; float:left; margin-right:5px'><input type="radio" name="extMetadataType" value="docId" id="extMetadataType_docId" onclick="javascript:setDisabledProperties(true, true, false, true)"/></div><div style="float: left;"><label for="extMetadataType_docId">Document ID Field</label></div><div id="documentIdFieldStar" style="text-align: right; color: red; font-weight: bold; margin-right: 0.3em; float: right; visibility: hidden;">*</div></td>
<td colspan="1" rowspan="1" style="white-space:nowrap"><input type="text" size="50" name="documentIdField" id="documentIdField" disabled="disabled"/></td>
</tr>
<tr valign="top"><td align="center"><div style="margin-left:45px; float: left;">Base URL</div><div id="baseURLStar" style="text-align: right; color: red; font-weight: bold; margin-right: 0.3em; float: right; visibility: hidden;">*</div></td>
<td colspan="1" rowspan="1" style="white-space:nowrap"><input type="text" size="50" name="baseURL" id="baseURL" disabled="disabled"/></td>
</tr>
<tr valign="top"><td colspan="1" rowspan="1" style="white-space:nowrap"><div style="float: left;">Authorization SQL Query</div></td>
<td colspan="1" rowspan="1" style="white-space:nowrap"><textarea rows="10" cols="50" name="authZQuery" id="authZQuery"></textarea></td>
</tr>
]]></FormSnippet>
<ConnectorConfigXml><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!--
Bean for encapsulation of all the configuration parameter needed for a
working Database Connector instance.
-->
<bean id="db-connector-config" class="com.google.enterprise.connector.db.DBContext"
parent="database-connector-defaults" singleton="false"> <!--
Parameter for fetching number of rows in a single call to the repository.
-->
<!--
<property name="numberOfRows" value="500"></property>
--> <!--
Replace the minValue with minimum key value when configuring the connector
with with parameterized query. Default value -1 is for minimum value
comparison with the result set key values for the first time to compute
the next highest order key.
-->
<!--
<property name="minValue" value="-1"></property>
--> <!--
Flag to determine whether the SQL query is parameterized.
-->
<!--
<property name="parameterizedQueryFlag" value="true"></property>
--> <!--
Flag to specify whether NULL values sort high or low in ORDER BY queries.
This can usually be determined by examining the DatabaseMetadata.
However, if that information is unavailable or incorrect, you can
explicitly specify the ordering here.
-->
<!--
<property name="nullsAreSortedLow" value="true"></property>
--> <!--
A java.text.Collator implementation that mimics the sorting done by
the database ORDER BY clause specified in the Traversal SQL query
for text values (CHAR, VARCHAR, etc).
By default, the connector uses the Collator for the current default
locale, with TERTIARY strength (case and accent sensitive), and
CANONICAL_DECOMPOSITION of accented characters.
See CollatorConfiguration examples in the Database connector Wiki:
http://code.google.com/p/google-enterprise-connector-database/wiki/ConfiguringCollator
-->
<!--
This example uses the java.text.Collator static factory method to
get a Collator for the current default locale, then set the strength
to be case-sensitive and accent-sensitive.
-->
<!--
<property name="collator">
<bean class="java.text.Collator" factory-method="getInstance">
<property name="strength">
<util:constant static-field="java.text.Collator.TERTIARY"/>
</property>
<property name="decomposition">
<util:constant static-field="java.text.Collator.CANONICAL_DECOMPOSITION"/>
</property>
</bean>
</property>
-->
</bean>
</beans>
]]></ConnectorConfigXml>
</ConfigureResponse>
</CmResponse>

3)  创建连接器实例

提交地址:http://localhost:8080/connector-manager/setConnectorConfig
提交方式:POST
提交数据:

<ConnectorConfig>
<Lang>zh</Lang>
<ConnectorName>default_collectionName_dbconnector_1401727454046</ConnectorName>
<ConnectorType>DBConnector</ConnectorType>
<Update>false</Update>
<Param name="driverClassName" value="com.mysql.jdbc.Driver"/>
<Param name="connectionUrl" value="jdbc:mysql://localhost:3306/hedgehog?useUnicode=true&amp;characterEncoding=utf-8"/>
<Param name="login" value="root"/>
<Param name="password" value="admin"/>
<Param name="sqlQuery" value="select * from biz_document"/>
<Param name="primaryKeysString" value="docID"/>
<Param name="lastModifiedDate" value="doc_crawl_date"/>
<Param name="extMetadataType" value="noExt"/>
<Param name="xslt" value=""/>
<Param name="authZQuery" value=""/>
<Param name="ctl00$PageBody$Button1" value="确定"/>
</ConnectorConfig>

返回数据:

<CmResponse>
<StatusId>0</StatusId>
</CmResponse>

4) 设置调度配置信息

提交地址:http://localhost:8080/connector-manager/setSchedule
提交方式:POST
提交数据:

<ConnectorSchedules>
<ConnectorName>default_collectionName_dbconnector_1401727454046</ConnectorName>
<disabled>true</disabled>
<load>1000</load>
<RetryDelayMillis>5000</RetryDelayMillis>
<TimeIntervals>0-0</TimeIntervals>
</ConnectorSchedules>

返回数据:

<CmResponse>
<StatusId>0</StatusId>
</CmResponse>

5) 获取调度配置信息

http://127.0.0.1:8080/connector-manager/getSchedule?ConnectorName=default_collectionName_dbconnector_1401727454046

提交方式:GET

参数 ConnectorName 值为连接实例名

返回数据:

<CmResponse>
<StatusId>0</StatusId>
<ConnectorStatus>
<ConnectorName>default_collectionName_dbconnector_1401727454046</ConnectorName>
<ConnectorType>DBConnector</ConnectorType>
<Status>0</Status>
<ConnectorSchedules>#default_collectionName_dbconnector_1401727454046:1000:5000:0-0</ConnectorSchedules>
</ConnectorStatus>
</CmResponse>

6) 获取连接实例状态

提交地址:http://127.0.0.1:8080/connector-manager/getConnectorStatus?ConnectorName=default_collectionName_dbconnector_1401727454046
提交方式:GET

参数 ConnectorName 值为连接实例名

返回数据:

<CmResponse>
<StatusId>0</StatusId>
<ConnectorStatus>
<ConnectorName>default_collectionName_dbconnector_1401727454046</ConnectorName>
<ConnectorType>DBConnector</ConnectorType>
<Status>0</Status>
<ConnectorSchedules version="3">#default_collectionName_dbconnector_1401727454046:1000:5000:0-0</ConnectorSchedules>
</ConnectorStatus>
</CmResponse>

7) 获取连接实例配置信息

提交地址:http://127.0.0.1:8080/connector-manager/getConnectorConfig?ConnectorName=default_collectionName_dbconnector_1401727454046

提交方式:GET

参数 ConnectorName 值为连接实例名

返回数据:(编码)

<CmResponse>
<StatusId>0</StatusId>
<ConfigureResponse>
<Param name="googlePropertiesVersion" value="3"/>
<Param name="sqlQuery" value="select * from biz_document"/>
<Param name="authZQuery" value=""/>
<Param name="driverClassName" value="com.mysql.jdbc.Driver"/>
<Param name="extMetadataType" value="noExt"/>
<Param name="password" value="admin"/>
<Param name="primaryKeysString" value="docID"/>
<Param name="xslt" value=""/>
<Param name="connectionUrl" value="jdbc:mysql://localhost:3306/hedgehog?useUnicode=true&characterEncoding=utf-8"/>
<Param name="lastModifiedDate" value="doc_crawl_date"/>
<Param name="login" value="root"/>
<Param name="ctl00$PageBody$Button1" value="确定"/>
</ConfigureResponse>
</CmResponse>

8)设置调度配置信息(启动连接器实例)

提交地址:http://localhost:8080/connector-manager/setSchedule
提交方式:POST
提交数据:

<ConnectorSchedules>
<ConnectorName>default_collectionName_dbconnector_1401727454046</ConnectorName>
<load>1000</load>
<RetryDelayMillis>5000</RetryDelayMillis>
<TimeIntervals>0-0</TimeIntervals>
</ConnectorSchedules>

返回数据:

<CmResponse>
<StatusId>0</StatusId>
</CmResponse>

9) 停止连接器实例

提交地址:http://127.0.0.1:8080/connector-manager/stopConnector?ConnectorName=default_collectionName_dbconnector_1401339529599
提交方式:GET
返回数据:

<CmResponse>
<StatusId>0</StatusId>
<ConnectorStatus>
<ConnectorName>default_collectionName_dbconnector_1401339529599</ConnectorName>
<ConnectorType>DBConnector</ConnectorType>
<Status>0</Status>
</ConnectorStatus>
</CmResponse>

10) 移除连接器实例

提交地址:http://127.0.0.1:8080/connector-manager/removeConnector?ConnectorName=default_collectionName_dbconnector_1401339529599
提交方式:GET
返回数据:

<CmResponse>
<StatusId>0</StatusId>
</CmResponse>

---------------------------------------------------------------------------

本系列企业搜索引擎开发之连接器connector系本人原创

转载请注明出处 博客园 刺猬的温驯

本人邮箱: chenying998179@163#com (#改为.)

本文链接 http://www.cnblogs.com/chenying99/p/3726862.html

企业搜索引擎开发之连接器connector(十七)的更多相关文章

  1. 企业搜索引擎开发之连接器connector(二十七)

    ChangeQueue类实现ChangeSource接口,声明了拉取下一条Change对象的方法 * A source of {@link Change} objects. * * @since 2. ...

  2. 企业搜索引擎开发之连接器connector(三十)

    连接器里面采用的什么样的数据结构,我们先从Document迭代器开始入手,具体的Document迭代器类都实现了DocumentList接口,该接口定义了两个方法 public interface D ...

  3. 企业搜索引擎开发之连接器connector(二十九)

    在哪里调用监控器管理对象snapshotRepositoryMonitorManager的start方法及stop方法,然后又在哪里调用CheckpointAndChangeQueue对象的resum ...

  4. 企业搜索引擎开发之连接器connector(二十八)

    通常一个SnapshotRepository仓库对象对应一个DocumentSnapshotRepositoryMonitor监视器对象,同时也对应一个快照存储器对象,它们的关联是通过监视器管理对象D ...

  5. 企业搜索引擎开发之连接器connector(二十六)

    连接器通过监视器对象DocumentSnapshotRepositoryMonitor从上文提到的仓库对象SnapshotRepository(数据库仓库为DBSnapshotRepository)中 ...

  6. 企业搜索引擎开发之连接器connector(二十五)

    下面开始具体分析连接器是怎么与连接器实例交互的,这里主要是分析连接器怎么从连接器实例获取数据的(前面文章有涉及基于http协议与连接器的xml格式的交互,连接器对连接器实例的设置都是通过配置文件操作的 ...

  7. 企业搜索引擎开发之连接器connector(二十四)

    本人在上文中提到,连接器实现了两种事件依赖的机制 ,其一是我们手动操作连接器实例时:其二是由连接器的自动更新机制 上文中分析了连接器的自动更新机制,即定时器执行定时任务 那么,如果我们手动操作连接器实 ...

  8. 企业搜索引擎开发之连接器connector(二十三)

    我们在前面的文章已经看到,ConnectorCoordinatorImpl类也实现了ChangeHandler接口,本文接下来分析实现该接口的作用 class ConnectorCoordinator ...

  9. 企业搜索引擎开发之连接器connector(二十二)

    下面来分析线程执行类,线程池ThreadPool类 对该类的理解需要对java的线程池比较熟悉 该类引用了一个内部类 /** * The lazily constructed LazyThreadPo ...

随机推荐

  1. log4net 使用指南,最常遇到的问题整理。。。

    一.    Log4net特征    Log4net是一个用于.NET开发环境的日志记录组件,由于它的超快及超灵活,很多大型的应用都会用到.    它有如下特点:    1.自定义日志输出级别    ...

  2. Run-time Settings 运行时设置

    1.执行顺序设置和执行概率设置 2.迭代之间的等待时间设置 3.日志设置 4.思考时间 5.杂项 线程进程选择: 一般服务器没有安全机制选择线程执行 但是有安全机制的话 比如第一个进程50个线程 第二 ...

  3. Monkey记录

    1.查找包名方法 方法一: sdk里面的appt 以ES文件浏览器为例,命令行中切换到aapt.exe目录执行:aapt dump badging E:\apk\es3.apk 方法二: 查看data ...

  4. Jmeter的参数配置

    Ramp-up Period(in seconds) [1]决定多长时间启动所有线程.如果使用10个线程,ramp-up period是100秒,那么JMeter用100秒使所有10个线程启动并运行. ...

  5. 使用PHP自带zlib函数 几行代码实现PHP文件打包下载zip

    <?php //获取文件列表 function list_dir($dir){ $result = array(); if (is_dir($dir)){ $file_dir = scandir ...

  6. java中一个简单的下载示例

    首先在tomcat服务器下的webapps的download项目下建一个doc文件夹,再建个test.doc.防止控指针异常 DownLoad.java代码 package com.down; imp ...

  7. css字体中英文对照表(转)

     在css文件中,我们常看到有些字体名称变成了乱码,这是由于网页开发者将中文字体的名字直接写成了中文,而css文件本身没有声明字符编码方式,查看时就出现了乱码.为了避免这种乱码状况出现,可以将css文 ...

  8. leetcode67

    public class Solution { public string AddBinary(string a, string b) { var list = new List<string& ...

  9. 【bzoj1096】仓库建设 斜率优化dp

    AC通道:http://www.lydsy.com/JudgeOnline/problem.php?id=1096 [题解] 设输入的三个数组为a,b,c sumb维护b数组的前缀和,sumab维护a ...

  10. java把流抛给浏览器下载时,当下载的文件文件名为中文时,出现中文名被替换为“----------”的情况

    比如说,下载的文件名为: 软件分析报告.docx,当使用流抛给浏览器下载时,浏览器下载的文件为:-----------.docx 出现这种情况的原因:大体的原因就是header中只支持ASCII,所以 ...