1. Getting the IP Address of a Hostname
try
{
InetAddress addr = InetAddress.getByName("yahoo.com");
byte[] ipAddr = addr.getAddress();
// Convert to dot representation
String ipAddrStr = "";
for (int i=0; i<ipAddr.length; i++) {
if (i > 0) {
ipAddrStr += ".";
}
ipAddrStr += ipAddr[i]&0xFF;
}
}
catch (UnknownHostException e) {
}
2. Getting the Hostname of an IP Address
This example attempts to retrieve the hostname for an IP address.
Note that
getHostName()
may not succeed, in which case it simply
returns the IP address.
try {
// Get hostname by textual representation of IP address
InetAddress addr = InetAddress.getByName("127.0.0.1");
// Get hostname by a byte array containing the IP address
byte[] ipAddr = new byte[]{127, 0, 0, 1};
addr = InetAddress.getByAddress(ipAddr);
// Get the host name
String hostname = addr.getHostName();
// Get canonical host name
String hostnameCanonical = addr.getCanonicalHostName();
} catch (UnknownHostException e) {
}
3. Getting the IP Address and Hostname of the Local Machine
try {
InetAddress addr = InetAddress.getLocalHost();
// Get IP Address
byte[] ipAddr = addr.getAddress();
// Get hostname
String hostname = addr.getHostName();
} catch (UnknownHostException e) {
}
http://forums.seochat.com/alexa-ranking-49/how-does-alexa-work-140.html
In the
last digest about Greatest software ever written, I noted a worm named Morris which is ranked 12 of greatest software by the author. Actually, after finishing my clustering searching enigne development which is based on Lucene, i am studying p2p architecture for my distributed searching engine (more precisely is webcrawler part). When I am reading some p2p loopup protocol papers such as
Chord, I also noticed a guy named Morris who is one of the developers. Hmmm,? this is the same Morris, from
wiki, I know that guys is now an associate professor in MIT, and was indicted because of the damage by his Morris worm. Anyway, I'd like to say that it is very interesting to know some stories about those geeks.
http://www.informationweek.com/shared/printableArticle.jhtml?articleID=191901844
12. The Morris worm11. Google search rank10. Apollo guidance system 9. Excel spreadsheet 8. Macintosh OS 7. Sabre system 6. Mosaic browser 5. Java language 4. IBM System 360 OS
3. gene-sequencing software at the Institute for Genomic Research
2. IBM's System R
1. Unix System IIIHow r u thinking?
有興趣的朋友可以參見
原文下面是本人的一些大致的翻譯:
------------------------------------------------------------
大伙都知道,Google是運(yùn)行在很多的Linux(GNU)系統(tǒng)的服務(wù)器上的,而這只是它支持免費(fèi)軟件的一個(gè)方面。其他的比如,
Summer of Code, 現(xiàn)在已成為一個(gè)生產(chǎn)很多優(yōu)秀代碼和項(xiàng)目的孵化基地,并且最近開放的
Code Repository, 大有取代sourceforge.net(筆者注:廣大開源的據(jù)點(diǎn))之趨勢。一方面,Google
貢獻(xiàn)出它的Picasa(Linux(GNU)平臺(tái))(筆者注:一個(gè)圖片管理軟件),并被
Wine(筆者注:Linux/Unix上的Windows,建于x-window之上)所使用;另一方面,Google也贊助一些開源項(xiàng)目,如
Sri Lanka,大概有$25,000之多。
?
當(dāng)然,Google也會(huì)秘密地進(jìn)行一些開源的資助。比如,令我們大伙驚訝的Mozilla Foundation(筆者注:大家熟悉的另一瀏覽器Firefox)居然在去年有賺到
72個(gè)million?-- 就是在Firefox上把Google的搜索引擎作為缺省的搜索引擎。
2005年的1月份,Google把Ben Goodger招為靡下。此人乃Firefox的首席工程師,并且是幾個(gè)主要開源編碼者之一。到了年末,Guido van Rossum, Python的始創(chuàng)人,也加入了Google。最近,Linux2.6核心的維護(hù)人,Andrew Morton也宣稱即將離開
OSDL并投奔到Google.
所有的這些,都意味著開源領(lǐng)域的大變遷。
記得在最初的那些年代里,人們都為著自己的興趣愛好在業(yè)余時(shí)間里一邊工作一邊學(xué)習(xí)地奮力地寫著自己的代碼。突然,第一個(gè).com的時(shí)代來臨,不少早期的開源公司開始聘請(qǐng)頂級(jí)程序員:如核心編碼員Alan Cox, David Miller,Stephen Tweedie等人紛紛來到Red Hat, 還有一些去了Linuxcare。
隨著第一個(gè).com泡沫經(jīng)濟(jì)的破滅,高手們被迫紛紛尋找新的工作,不少人去了新興之秀OSDL。基于這樣的一個(gè)背景,Google的興起以及大攬人才意味著早期公司廣具人才的模式的回歸。當(dāng)然,這次他們的工作都間接的有關(guān)于Google的主要市場策略。
Google的策略是精明的,看看最近招的人,Goodger和Morton,一個(gè)是瀏覽器,一個(gè)是操作系統(tǒng)。無不顯示出其與Microsoft暗暗較勁的決心。
當(dāng)然還有另一方面的原因,可能不是那么明顯,那就是最近的一些
爭論,關(guān)于Google能否履行其最初對(duì)開源領(lǐng)域許下的諾言。矛頭指向Google是否應(yīng)該公開它的源碼?因?yàn)镚oogle用了不少開源的東西。
所以,從某種角度上講,招一些開源黑客人士入帳遠(yuǎn)遠(yuǎn)比把代碼隨處發(fā)布好的多。
那些關(guān)于用了開源的代碼的公司是不是也應(yīng)該開放他們的代碼的爭論不僅僅涉及到Google。其他的一些主要得益者如Yahoo, 其最近正活躍于收購一些Web 2.0的公司如
Flickr 和
Del.icio.us,這些都很顯然有著開源的印記,當(dāng)然它沒有Google那樣與開源的關(guān)系那么源遠(yuǎn)流長,不過Yahoo也開始著手吸引開源人才。
People are still talking about web 2.0, I am not sure that is pure technical term. In my understanding, maybe most of meaning of web 2.0 is its marketing meaning. that is, web is becoming commonality and people generate the web's content. Again, i am not sure?what is the place of web service in web 2.0, in my understanding, the web is not merely client-server marketing model (I am not talking web structure here), but an?interactive community. But question is , who gonna be the operator or administrator of this community or if there?are any game?rules?needed to follow?? will that be another utopian ?
Well, on a technical layer, I'd like to shed some lights on so-called web standard trends
1. front end --
???????? CSS ----> layout
?????????XML ----> data?
?????????XHTML ----> markup
?????????Javascript & DOM ----> behavior +
XMLHttpRequest?--> AJAX ?
2. back end --?
?????????some open source projects such as Ruby on Rail...
let me know how you are thinking...
作為
Lucene和
Nutch兩大Apach Open Source Project的始創(chuàng)人(其實(shí)還有Lucy, Lucene4C 和Hadoop等相關(guān)子項(xiàng)目),Doug Cutting 一直為搜索引擎的開發(fā)人員所關(guān)注。他終于在為Yahoo以Contractor的身份工作4年后,于今年正式以Employee的身份加入Yahoo
下面是筆者在工作之余,翻譯其一篇2年前的訪談錄,
原文(Doug Cutting Interview)在網(wǎng)上Google一下就容易找到。希望對(duì)搜索引擎開發(fā)的初學(xué)者起到一個(gè)拋磚引玉的效果。
(注:翻譯水平有限,不求雅,只求信,達(dá)。希望見諒)
1。請(qǐng)問你以何為生?你是如何開始從事搜索引擎開發(fā)的?
我主要在家從事兩個(gè)與搜索有關(guān)的開源項(xiàng)目的開發(fā): Lucene和Nutch.?錢主要來自于一些與這些項(xiàng)目相關(guān)的一些合同中。目前Yahoo! Labs?有一部分贊助在Nutch上。這兩個(gè)項(xiàng)目還有一些其他的短期合同?。
2。你能大概給我們講解一下Nutch嗎?以及你將在哪方面運(yùn)用它?我還是先說一下Lucene吧。Lucene其實(shí)是一個(gè)提供全文文本搜索的函數(shù)庫,它不是一個(gè)應(yīng)用軟件。它提供很多API函數(shù)讓你可以運(yùn)用到各種實(shí)際應(yīng)用程序中。現(xiàn)在,它已經(jīng)成為Apache的一個(gè)項(xiàng)目并被廣泛應(yīng)用著。這里列出一些
已經(jīng)使用Lucene的系統(tǒng)。
Nutch是一個(gè)建立在Lucene核心之上的Web搜索的實(shí)現(xiàn),它是一個(gè)真正的應(yīng)用程序。也就是說,你可以直接下載下來拿過來用。它在Lucene的基礎(chǔ)上加了網(wǎng)絡(luò)爬蟲和一些和Web相關(guān)的東東。其目的就是想從一個(gè)簡單的站內(nèi)索引和搜索推廣到全球網(wǎng)絡(luò)的搜索上,就像Google和Yahoo一樣。當(dāng)然,和那些巨人競爭,你得動(dòng)一些腦筋,想一些辦法。我們已經(jīng)測試過100M的網(wǎng)頁,并且它的設(shè)計(jì)用在超過1B的網(wǎng)頁上應(yīng)該沒有問題。當(dāng)然,讓它運(yùn)行在一臺(tái)機(jī)器上,搜索一些服務(wù)器,也運(yùn)行的很好。
3。在你看來,什么是搜索引擎的核心元素?也就說,一般的搜索引擎軟件可以分成哪幾個(gè)主要部分或者模塊?讓我想想,大概是如下幾塊吧:
?-- 攫取(fetching):就是把被指向的網(wǎng)頁下載下來。
?-- 數(shù)據(jù)庫:保存攫取的網(wǎng)頁信息,比如那些網(wǎng)頁已經(jīng)被攫取,什么時(shí)候被攫取的以及他們又有哪些鏈接的網(wǎng)頁等等。
?-- 鏈接分析:對(duì)剛才數(shù)據(jù)庫的信息進(jìn)行分析,給每個(gè)網(wǎng)頁加上一些權(quán)值(比如PageRank,WebRank什么的),以便對(duì)每個(gè)網(wǎng)頁的重要性有所估計(jì)。不過,在我看來,索引那些網(wǎng)頁標(biāo)記(Anchor)里面的內(nèi)容更為重要。(這也是為什么諸如Google Bombing如此高效的原因)
?-- 索引(Indexing): 就是對(duì)攫取的網(wǎng)頁內(nèi)容,以及鏈入鏈接,鏈接分析權(quán)值等信息進(jìn)行索引以便迅速查詢。
?-- 搜索(Searching): 就是通過一個(gè)索引進(jìn)行查詢?nèi)缓蟀凑站W(wǎng)頁排名顯示。
當(dāng)然,為了讓搜索引擎能夠處理數(shù)以億計(jì)的網(wǎng)頁,以上的模塊都應(yīng)該是分布式的。也就是說,可以在多臺(tái)機(jī)器上并行運(yùn)行。
4。你剛才說大家可以立馬下載Nutch運(yùn)行在自己的機(jī)器上。這是不是說,即便那些對(duì)Apache服務(wù)器沒有掌控權(quán)的網(wǎng)站管理員在短時(shí)間內(nèi)就可以使用Nutch?很不幸,估計(jì)他們大都沒戲。因?yàn)镹utch還是需要一個(gè)Java servlet的容器(筆者注:比如Tomcat)。而這個(gè)有些ISP支持,但大都不支持。(筆者注: 只有對(duì)Apache服務(wù)器有掌控權(quán),你才能在上面安裝一個(gè)Tomcat之類的東東)
5。我可以把Lucene和Google Web API結(jié)合起來嗎?或者和其他的一些我先前寫過的應(yīng)用程序結(jié)合起來?
有那么一幫人已經(jīng)為Nutch寫了一些類似Google的API, 但還沒有一個(gè)融入現(xiàn)在的系統(tǒng)。估計(jì)不久的將來就行了。
6。你認(rèn)為目前實(shí)現(xiàn)一個(gè)搜索引擎最大的障礙在哪里?是硬件,存儲(chǔ)障礙還是排名算法?還有,你能不能告訴我大概需要多大的空間搜索引擎才能正常工作,就說我只想寫一個(gè)針對(duì)搜索成千上百萬的RSS feeds的一個(gè)搜索引擎吧。Nutch大概一個(gè)網(wǎng)頁總共需要10kb的空間吧。Rss feeds的網(wǎng)頁一般都比較小(筆者注: Rss feeds都是基于xml的文本網(wǎng)頁,所以不會(huì)很大),所以應(yīng)該更好處理吧。當(dāng)然Nutch目前還沒有針對(duì)RSS的支持。(筆者注:實(shí)際上,API里面有針對(duì)RSS的數(shù)據(jù)結(jié)構(gòu)和解析)
7。從Yahoo! Labs拿到資金容易嗎?哪些人可以申請(qǐng)?你又要為之做出些什么作為回報(bào)?我是被邀請(qǐng)的,我沒有申請(qǐng)。所以我不是很清楚個(gè)中的流程。
8。Google有沒有表示對(duì)Nutch感興趣?我和那邊的一些家伙談過,包括Larry Page(筆者注: Google兩個(gè)創(chuàng)始人之一)。他們都很愿意提供一些幫助,但是他們也無法找到一種不會(huì)幫助到他們競爭對(duì)手的合適方式。
9。你有實(shí)現(xiàn)你自己的PageRank或者WebRank算法系統(tǒng)在你的Nutch里嗎?什么是你做網(wǎng)頁排名(Ranking)的考慮?
是的,Nutch里面有一個(gè)鏈接分析模塊。它是可選的,因?yàn)閷?duì)于站內(nèi)搜索來說,網(wǎng)頁排名是不需要的。
10。我想你以前有聽說過,就是對(duì)于一個(gè)開源的搜索引擎,是不是意味著同樣會(huì)給那些搞搜索引擎優(yōu)化(SEO)的黑客們有機(jī)可趁?恩,有可能。
就說利用反向工程破解的非開源搜索引擎中的最新的反垃圾信息檢測算法需要大概6個(gè)月的時(shí)間。對(duì)于一個(gè)開放源碼的搜索引擎來說,破解將會(huì)更快。但不管怎么說,那些制造垃圾信息者最終總能找到破解辦法,唯一的區(qū)別就是破解速度問題。所以最好的反垃圾信息技術(shù),不管開源也好閉源也好,就是讓別人知道了其中的機(jī)制之后也能繼續(xù)工作那一種。
還有,如果這六月中你是把檢測出來的垃圾信息從你的索引中移除,他們無計(jì)可施,他們只能改變他們的站點(diǎn)。如果你的垃圾信息檢測是基于對(duì)一些網(wǎng)站中好的和壞的例子的統(tǒng)計(jì)分析,你可以徹夜留意那些新的垃圾信息模式并在他們有機(jī)會(huì)反應(yīng)之前將他們移除。
開源會(huì)使得禁止垃圾信息的任務(wù)稍稍艱巨一點(diǎn),但不是使之成為不可能。況且,那些閉源的搜索引擎也并沒有秘密地解決這些問題。我想閉源的好處就是不讓我們看到它其實(shí)沒有我們想象的那么好。
11。Nutch和分布式的網(wǎng)絡(luò)爬蟲Grub相比怎么樣?你是怎么想這個(gè)問題的?我能說的就是,Grub是一個(gè)能夠讓網(wǎng)民們貢獻(xiàn)一點(diǎn)自己的硬件和帶寬給巨大的LookSmart的爬行任務(wù)的一個(gè)工程。它只有客戶端是開源,而服務(wù)端沒有。所以大家并不能配置自己的Grub服務(wù),也不能訪問到Grub收集的數(shù)據(jù)。
更一般意義的分布式網(wǎng)絡(luò)爬行又如何?當(dāng)一個(gè)搜索引擎變得很大的時(shí)候,其爬行上的代價(jià)相對(duì)搜索上需要付出的代價(jià)將是小巫見大巫。所以,一個(gè)分布式爬蟲并不能是顯著降低成本,相反它會(huì)使得一些已經(jīng)不是很昂貴的東西變得很復(fù)雜(筆者注:指pc和硬盤之類的硬件)。所以這不是一個(gè)便宜的買賣。
廣泛的分布式搜索是一件很有趣的事,但我不能肯定它能否實(shí)現(xiàn)并保持速度足夠的快。一個(gè)更快的搜索引擎就是一個(gè)更好的搜索引擎。當(dāng)大家可以任意快速更改查詢的時(shí)候,他們就更能在他們失去耐心之前頻繁找到他們所需的東西。但是,要建立一個(gè)不到1秒內(nèi)就可以搜索數(shù)以億計(jì)的網(wǎng)頁的廣泛的分布式搜索引擎是很難的一件事,因?yàn)槠渲芯W(wǎng)絡(luò)有很高的延時(shí)。大都的半秒時(shí)間或者像Google展示它的查詢那樣就是在一個(gè)數(shù)據(jù)中心的網(wǎng)絡(luò)延時(shí)。如果你讓同樣一個(gè)系統(tǒng)運(yùn)行在千家萬戶的家里的PC上,即便他們用的是DSL和Cable上網(wǎng),網(wǎng)絡(luò)的延時(shí)將會(huì)更高從而使得一個(gè)查詢很可能要花上幾秒鐘甚至更長的時(shí)間。從而他也不可能會(huì)是一個(gè)好的搜索引擎。
12。你反復(fù)強(qiáng)調(diào)速度對(duì)于搜索引擎的重要性,我經(jīng)常很迷惑Google怎么就能這么快地返回查詢結(jié)果。你認(rèn)為他們是怎么做到的呢?還有你在Nutch上的經(jīng)驗(yàn)看法如何?我相信Google的原理和Nutch大抵相同:就是把查詢請(qǐng)求廣播到一些節(jié)點(diǎn)上,每個(gè)節(jié)點(diǎn)返回一些頁面的頂級(jí)查詢結(jié)果。每個(gè)節(jié)點(diǎn)上保存著幾百萬的頁面,這樣可以避免大多查詢的磁盤訪問,并且每個(gè)節(jié)點(diǎn)可以每秒同時(shí)處理成十上百的查詢。如果你想獲得數(shù)以億計(jì)的頁面,你可以把查詢廣播到成千的節(jié)點(diǎn)上。當(dāng)然這里會(huì)有不少網(wǎng)絡(luò)流量。
具體的在
這篇文章(
www.computer.org/ micro/mi2003/ m2022.pdf)中有所描述。
13。你剛才有提到垃圾信息,在Nutch里面是不是也有類似的算法?怎么區(qū)別垃圾信息模式比如鏈接場(Linkfarms)(筆者注:就是一群的網(wǎng)頁彼此互相鏈接,這是當(dāng)初在1999年被一幫搞SEO弄出來的針對(duì)lnktomi搜索引擎的使網(wǎng)頁的排名得到提高的一種Spamdexing方法)和那些正常的受歡迎的站點(diǎn)鏈接。
這個(gè),我們還沒有騰出時(shí)間做這塊。不過,很顯然這是一個(gè)很重要的領(lǐng)域。在我們進(jìn)入鏈接場之前,我們需要做一些簡單的事情:察看詞匯填充(Word stuffing)(筆者注:就是在網(wǎng)頁里嵌入一些特殊的詞匯,并且出現(xiàn)很多的次,甚至上百次,有些是人眼看不到的,比如白板寫白字等伎倆,這也是Spamdexing方法的一種),白板寫白字(White-on-white text),等等。
我想在一般意義上來說(垃圾信息檢測是其中的一個(gè)子問題),搜索質(zhì)量的關(guān)鍵在于擁有一個(gè)對(duì)查詢結(jié)果手工可靠評(píng)估的輔助措施。這樣,我們可以訓(xùn)練一個(gè)排名算法從而產(chǎn)生更好的查詢結(jié)果(垃圾信息的查詢結(jié)果是一種壞的查詢結(jié)果)。商業(yè)的搜索引擎往往會(huì)雇傭一些人進(jìn)行可靠評(píng)估。Nutch也會(huì)這樣做,但很顯然我們不能只接受那些友情贊助的評(píng)估,因?yàn)槟切├畔⒅圃煺吆苋菀讜?huì)防止那些評(píng)估。因此我們需要一種手段去建立一套自愿評(píng)估者的信任體制。我認(rèn)為一個(gè)平等評(píng)論系統(tǒng)(peer-review system),有點(diǎn)像Slashdot的karma系統(tǒng), 應(yīng)該在這里很有幫助。
14。你認(rèn)為搜索引擎在不久的將來路在何方?你認(rèn)為從一個(gè)開發(fā)者的角度來看,最大的障礙將在哪里?
很抱歉,我不是一個(gè)想象力豐富的人。我的預(yù)測就是在未來的十年里web搜索引擎將和現(xiàn)在的搜索引擎相差無幾。現(xiàn)在應(yīng)該屬于平穩(wěn)期。在最初的幾年里,網(wǎng)絡(luò)搜索引擎確實(shí)曾經(jīng)發(fā)展非常迅速。源于1994年的網(wǎng)絡(luò)爬蟲使用了標(biāo)準(zhǔn)的信息析取方法。直到1998年Google的出現(xiàn),其間更多的基于Web的方法得到了發(fā)展。從那以后,新方法的引入大大放慢了腳步。那些樹枝低的果實(shí)已被收獲。創(chuàng)新只有在剛發(fā)展的時(shí)候比較容易,越到后來越成熟,越不容易創(chuàng)新。網(wǎng)絡(luò)搜索引擎起源于上個(gè)世紀(jì)90年代,現(xiàn)在儼然已成一顆搖錢樹,將來很快會(huì)走進(jìn)人們的日常生活中。
至于開發(fā)上的挑戰(zhàn),我認(rèn)為操作上的可靠性將是一個(gè)大的挑戰(zhàn)。我們目前正在開發(fā)一個(gè)類似GFS(Google的文件系統(tǒng))的東西。它是巨型搜索引擎不可缺少的基石:你不能讓一個(gè)小組件的錯(cuò)誤導(dǎo)致一個(gè)大的癱瘓。你應(yīng)該很容易的讓系統(tǒng)擴(kuò)展,只需往硬件池里加更多硬件而不需繁縟的重新配置。還有,你不需要一大坨的操作人員完成,所有的一切將大都自己搞定。
----------------完----------------------
--? Getting Ready to Use CVS
First set the variable CVSROOT to /class/`username`/cvsroot
[Or any other directory you wish]
[For csh/tcsh: setenv CVSROOT ~/cvsroot]
[For bash/ksh: CVSROOT=~/cvsroot;export CVSROOT]
Next run
cvsinit. It will create this directory along with the subdirectory CVSROOT and put several files into CVSROOT.
-- How to put a project under CVS
A simple program consisting of multiple files is in /workspaces/project.
To put this program under cvs first
cd to /workspaces/projectNext
cvs import -m "Sample Program" project sample startCVS should respond with
N project/Makefile
N project/main.c
N project/bar.c
N project/foo.c
No conflicts created by this importIf your were importing your own program, you could now delete the original source.
(Of course, keeping a backup is always a good idea)
-- Basic CVS Usage
Now that you have added 'project' to your CVS repository, you will want to be able to modify the code.
To do this you want to check out the source. You will want to cd to your home directory before you do this.
cdcvs checkout projectCVS should respond with
cvs checkout: Updating project
U project/Makefile
U project/bar.c
U project/foo.c
U project/main.cThis creates the project directory in your home directory and puts the files: Makefile, bar.c, foo.c, and main.c into the directory along with a CVS directory which stores some information about the files.
You can now make changes to any of the files in the source tree.
Lets say you add a
printf("DONE\n"); after the function call to bar()
[Or just cp /class/bfennema/project_other/main2.c to main.c]
Now you have to check in the new copy
cvs commit -m "Added a DONE message." main.cCVS should respond with
Checking in main.c;
/class/'username'/cvsroot/project/main.c,v <-- main.c
new revision: 1.2; previous revision: 1.1
doneNote, the -m option lets you define the checking message on the command line. If you omit it you will be placed into an editor where you can type in the checking message.
-- Using CVS with Multiple Developers
To simulate multiple developers, first create a directory for your second developer.
Call it devel2 (Create it in your home directory).
Next check out another copy of project.
- HINT: cvs checkout project
Next, in the devel2/project directory, add a
printf("YOU\n"); after the
printf("BAR\n");[Or copy /class/bfennema/project_other/bar2.c to bar.c]
Next, check in bar.c as developer two.
- HINT: cvs commit -m "Added a YOU" bar.c
Now, go back to the original developer directory.
[Probably /class/'username'/project]
Now look at bar.c. As you can see, the change made by developer one has no been integrated into your version. For that to happen you must
cvs update bar.cCVS should respond with
U bar.cNow look at bar.c. It should now be the same as developer two's.
Next, edit foo.c as the original developer and add
printf("YOU\n"); after the
printf("FOO\n");[Or copy /class/bfennema/project_other/foo2.c to foo.c]
Then check in foo.c
- HINT: cvs commit -m "Added YOU" foo.c
Next, cd back to developer two's directory.
Add
printf("TOO\n"); after the
printf("FOO\n");[Or copy /class/bfennema/project_other/foo3.c to foo.c]
Now type
cvs status foo.cCVS should respond with
===================================================================
File: foo.c Status: Needs Merge
Working revision: 1.1.1.1 'Some Date'
Repository revision: 1.2 /class/'username'/cvsroot/project/foo.c,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: (none)
The various status of a file are:
Up-to-date
The file is identical with the latest revision in the repository.
Locally Modified
You have edited the file, and not yet committed your changes.
Needing Patch
Someone else has committed a newer revision to the repository.
Needs Merge
Someone else has committed a newer revision to the repository, and you have also made modifications to the file.
Therefore, this is telling use we need to merge our changes with the changes made by developer one. To do this
cvs update foo.cCVS should respond with
RCS file: /class/'username'/cvsroot/project/foo.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
Merging differences between 1.1.1.1 and 1.2 into foo.c
rcsmerge: warning: conflicts during merge
cvs update: conflicts found in foo.c
C foo.cSince the changes we made to each version were so close together, we must manually adjust foo.c to look the way we want it to look. Looking at foo.c we see:
void foo()
{
printf("FOO\n");
<<<<<<< foo.c
printf("TOO\n");
=======
printf("YOU\n");
>>>>>>> 1.2
}
We see that the text we added as developer one is between the ======= and the >>>>>>> 1.2.
The text we just added is between the ======= and the <<<<<<< foo.c
To fix this, move the
printf("TOO\n");to after the
printf("YOU\n");line and delete the additional lines the CVS inserted. [Or copy /class/bfennema/project_other/foo4.c to foo.c]
Next, commit foo.c
cvs commit -m "Added TOO" foo.cSince you issued a cvs update command and integrated the changes made by developer one, the integrated changes are committed to the source tree.
-- Additional CVS Commands
To add a new file to a module:
- Get a working copy of the module.
- Create the new file inside your working copy.
- use cvs add filename to tell CVS to version control the file.
- use cvs commit filename to check in the file to the repository.
Removing files from a module:
- Make sure you haven't made any uncommitted modifications to the file.
- Remove the file from the working copy of the module. rm filename.
- use cvs remove filename to tell CVS you want to delete the file.
- use cvs commit filename to actually perform the removal from the repository.
For more information see the cvs man pages or the cvs.ps file in cvs-1.7/doc.
---------------
copy from
http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/cvs/
reference:
http://java.sun.com/j2se/1.4.2/docs/guide/util/logging/overview.html
When reading GData source code, you will find that there are lots of generic-style code in it, which is one of several extensions of JDK 1.5. If you are using java 1.5 compiler, it is surely deserved to get some ideas about generic. Be noticed that Java generic looks like C++ Temple, but is quite different.
1. what is the idea of generic?
To simply say, generic is an idea of parameterizing type, including class type and other data types.
2. examples?
-- We are familar with some container types, such as Collection. Here is an example for our former (Java 1.4 or before) typical usage:
Vector myList = new Vector();
myList.add(new Integer(100));
Integer value = (Integer)myList.get(0);
now it is better to write like this for type safety: (Eclipse IDE will display type safety warnings for above code if under java 1.5 compiler option)
??Vector<Integer> myList = new Vector<Integer>();
??myList.add(new Integer(100));
??Integer value = myList.get(0);
-- the reason why write code like this is Class Vector has been defined as a generic:
public Class Vector<E>
{
??????void add(E x);
????? ......
}
-- when we see some angle brackets(invocations) shown in?declaration, that is a generic. The invocation is a parameterized type. to use this generic, we need specify an actual type argument. (such as Integer as above)
3. trick in generic
-- we know that the idea of generic makes some data type such as container more flexible or acceptable for inputting entries. But that will be also very tricky. To take container as an example of generic, one of tricks is?can we copy values from one container to another container? if you want to copy like following style, the answer is no.
List<String> ls = new ArrayList<String>();
List<Object> lo = ls; //compile time error!
-- though we know String is a subtype of Object, and we can assign a value of String to an Object. But we can not assign a List of String to a List of Object as a whole part(like reference to a variable). The reason is we can access inner part of List(I mean element here, if List is as a simple data type such as Object, maybe we can do that), that will make List type unsafe. So, Java 1.5 complier will not let you do that.
-- Look inside two styles of code in above examples(of 2), we might say that the older style looks more flexible, because myList can accept more data types besides Integer, but the new style in 1.5 can only take Integer values. Well, if we need more flexible, we apply wildcards for generic.
4. Wildcards and bounded wildcards
-- if we see something like Collection<?> c, there is a question mark in angle brackets. That is Wildcard, which means type is temporarily unknown but it will be replaced by any type.
-- if we see something like Collection<? extends Number> c, that is bounded wildcard, which means the elements in Collection has a supertype bound. You can not put any other type whose supertype is not Number into this Collection.
-- But, no matter wildcard or bounded wildcard, we can not put a specified type value in it, that is because wildcard means type is unknown, you can not give a value to unknown data type.
-- So, what hell can wildcard be used for ? return back the flexible idea we mentioned before. We need apply wildcard to describe a flexible idea in definition or declaration, not to do real things.
for example, we can define an method like this:
void printCollection(Collection<?> c)
{
??????for(Object e : c){System.out.println(e);}
}
see? that is flexible. You can call this function for any Collection. You can use elements in Collection<?>, just don't try to put something in it.
-- So the question is, if we wanna that flexibility for our method, and we also need put something in it during the subroutine. How can we do? and then, we need use generic method
5. Generic method
-- that means method declaration can also be parameterized.
-- example:
????public <T> void addCollection(List<T> objs, T obj)
? ?{
??????? objs.add(obj);
?? ?}
6. when to use generic method and when to use wildcard ?
-- if the type parameter is used only once, or it has no relationship to other arguments of method including the return type, then wildcard?is?better to use to decribe clearer and more concise meanings.
-- otherwise, generic method should be used.
example:
class Collection
{
??????public static <T, S extends T> void copy(List<T> dest, List<S> src){...}
}
can be better rewritten as :
class Collection
{
??????public static <T> void copy(List<T> dest, List<? extends T> src){...}
}
reference: http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf
http://dsonline.computer.org/portal/site/dsonline/menuitem.9ed3d9924aeb0dcd82ccc6716bbe36ec/index.jsp?&pName=dso_level1&path=dsonline/0507&file=w4sta.xml&xsl=article.xsl&;jsessionid=GZQWvln9z4JY2dXX8HyQ5f5KtRptqHRWvh17tjCXVbxHnGyzvTm2!554406865
http://java.sun.com/j2se/1.5.0/docs/guide/language/index.html
when I try to debug my webcrawler?by crawling?yahoo website, I found that when trying to connect to a website which URL is such as
http://www.youtube.com/w/Kak%E1?v=PIBe_V9PBIA&search=kak%C3%A1, the following exception will happen:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 12
?at java.lang.String.substring(Unknown Source)
?at sun.net.www.ParseUtil.unescape(Unknown Source)
?at sun.net.www.ParseUtil.decode(Unknown Source)
?at sun.net.www.ParseUtil.toURI(Unknown Source)
?at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
?at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
follow is simple testing code:
?
private static final String urlstring = "
???URL url = new URL(urlstring);
???
???URLConnection con = url.openConnection();
???
???con.connect();
since there?are no other explicit exceptions except MalformedURLException & IOException mentioned to catch for this code, I am not sure if it is a bug in Java for URL parsing...
anybody got some idea about that?
P.S. ok, somebody has pointed out that Runtime exceptions, like java.lang.StringIndexOutOfBoundsException, do not have to be declared, but they can be thrown. So i need catch StringIndexOutOfBoundsException this exception for my code. But in my understanding, the function should catch all the exceptions from lower functions, and then throw out if it can not handle them, thus we can catch those exception from deep functions. I am not sure Runtime exceptions are exceptional ...
Still working on Webcrawler part, the URL collection strategies are
under thinking. A URL frontier which stores the list of? activate URLs to
be parsed or downloaded will be applied to handle for synchonized I/O operations with
URL collection/Inventory, stuck by some issues:
1. Duplicate URL Elimination:
??? a. Host name aliases --> DNS Resolver
??? b. Omitted port numbers
??? c. Alternative paths on the same host
??? d. replication across difference host
??? e. non-sense links or session IDs embedded in URLs ?
2. Reachable of URL
3. Distributed Storage of URL Inventory and relative synchronization problem
4. Fetch strategies for URL Frontier or Fetchor to get activate links for parsing
5. Scheduler for fetching and updating URL collection: multi-thread or
single thread on each pc, when to decide re-parsing a page
7. URL-Seen test: if that page has been parsed and should it re-parse? which should be done before entering URL frontier...
8. Extensibility issues for those modules: Fetcher, Extractor/Filters, Collector...
9. Checkpointing for crawlering interupted: how to resume the crawler
job, how to split crawler jobs and distribute to different machines
seems that I need couple days to refine my systen architecture design...
Here is an article for effective I/O programming thought, mark it just
for future re-check my I/O design in distributed searching engine
system. Non-blocking synchronous mode was applied in my current system.
I need check it out if anything can do to improve the performance and
large scalability later.